void FileEndpoint::receive(Command_ptr command){ if(command->getCommand()=="exit" || command->getCommand()=="logout" || command->getCommand()=="close"){ FileEndpoint_ptr this_ptr = boost::static_pointer_cast<FileEndpoint>(shared_from_this()); close(); command->answer("closed file "+filename+"\n", this_ptr); } else if(command->getCommand()=="restart"){ stopPlayback(); seek(boost::date_time::not_a_date_time); startPlayback(); command->answer("playback of "+getId()+" restarted at beginning\n", this->shared_from_this()); } else if(command->getCommand()=="stop"){ stopPlayback(); command->answer("playback of "+getId()+" stopped\n", this->shared_from_this()); } else if(command->getCommand()=="play"){ startPlayback(); command->answer("playback of "+getId()+" started\n", this->shared_from_this()); } else if(command->getCommand()=="record"){ record(); command->answer("record to "+getId()+" started\n", this->shared_from_this()); } else{ NMEAEndpoint::receive(command); } }
// Set the model, this also resets the camera void ModelPreview::setModel(const std::string& model) { // If the model name is empty, release the model if (model.empty()) { if (_modelNode) { _entity->removeChildNode(_modelNode); } _modelNode.reset(); stopPlayback(); return; } // Set up the scene if (!_entity) { getScene(); // trigger a setupscenegraph call } if (_modelNode) { _entity->removeChildNode(_modelNode); } _modelNode = GlobalModelCache().getModelNode(model); if (_modelNode) { _entity->addChildNode(_modelNode); // Trigger an initial update of the subgraph GlobalFilterSystem().updateSubgraph(getScene()->root()); // Reset camera if the model has changed if (model != _lastModel) { // Reset preview time stopPlayback(); // Reset the rotation to the default one _rotation = Matrix4::getRotationAboutZDegrees(45); _rotation = _rotation.getMultipliedBy(Matrix4::getRotation(Vector3(1,-1,0), 45)); // Calculate camera distance so model is appropriately zoomed _camDist = -(_modelNode->localAABB().getRadius() * 5.0f); } _lastModel = model; } // Redraw queueDraw(); }
bool PlaybackHelper::startPlayback() { // setup DeckLink Output interface if (! setupDeckLinkOutput()) goto bail; // preroll a few frames if (! scheduleNextFrame(true)) goto bail; // start playback if (m_deckLinkOutput->StartScheduledPlayback(0, m_timeScale, 1.0) != S_OK) { fprintf(stderr, "Could not start playback\n"); goto bail; } printf("Playback started\n"); m_playbackStarted = true; // Start the watchdog pinging thread if (pthread_create(&m_watchdogThread, NULL, pingWatchdogFunc, this) != 0) { fprintf(stderr, "Error starting watchdog pinging thread\n"); goto bail; } bail: if (! m_playbackStarted) stopPlayback(); return m_playbackStarted; }
void testApp::keyReleased(int key) { switch(key) { case 'q': if(!record) playback = !playback; if(record) startRecording(); else stopRecording(); break; case 'r': if(!playback) record = !record; if(playback) startPlayback(); else stopPlayback(); break; case 'p': paused = !paused; break; case keyUp: angle += 5; } }
void VideoWindow::mediaSelected(QString filename) { // stop any current playback stopPlayback(); // release whatever is already loaded if (m) libvlc_media_release(m); m = NULL; if (filename.endsWith("/DVD") || (filename != "" && QFile(filename).exists())) { #ifdef Q_OS_LINUX QString fileURL = "file://" + filename.replace(" ","%20").replace("\\", "/"); #else // A Windows "c:\xyz\abc def.avi" filename should become file:///c:/xyz/abc%20def.avi QString fileURL = "file:///" + filename.replace(" ","%20").replace("\\", "/"); #endif //qDebug()<<"file url="<<fileURL; /* open media */ m = libvlc_media_new_path(inst, filename.endsWith("/DVD") ? "dvd://" : fileURL.toLatin1()); /* set the media to playback */ if (m) libvlc_media_player_set_media (mp, m); m_MediaChanged = true; } }
VideoWindow::~VideoWindow() { if (!init) return; // we didn't initialise properly so all bets are off #if (defined Q_OS_LINUX) && (QT_VERSION < 0x050000) && (defined GC_VIDEO_VLC) // unembed vlc backend first x11Container->discardClient(); #endif stopPlayback(); #ifdef GC_VIDEO_VLC // VLC /* No need to keep the media now */ if (m) libvlc_media_release (m); /* nor the player */ libvlc_media_player_release (mp); // unload vlc libvlc_release (inst); #endif #ifdef GC_VIDEO_QT5 // QT MEDIA delete mp; delete wd; #endif }
void Engine::startRecording() { if (m_audioInput) { if (QAudio::AudioInput == m_mode && QAudio::SuspendedState == m_state) { m_audioInput->resume(); } else { m_spectrumAnalyser.cancelCalculation(); spectrumChanged(0, 0, FrequencySpectrum()); m_buffer.fill(0); setRecordPosition(0, true); stopPlayback(); m_mode = QAudio::AudioInput; CHECKED_CONNECT(m_audioInput, SIGNAL(stateChanged(QAudio::State)), this, SLOT(audioStateChanged(QAudio::State))); CHECKED_CONNECT(m_audioInput, SIGNAL(notify()), this, SLOT(audioNotify())); m_count = 0; m_dataLength = 0; emit dataLengthChanged(0); m_audioInputIODevice = m_audioInput->start(); CHECKED_CONNECT(m_audioInputIODevice, SIGNAL(readyRead()), this, SLOT(audioDataReady())); } } }
void Engine::audioStateChanged(QAudio::State state) { ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state << "to" << state; if (QAudio::IdleState == state && m_file && m_file->pos() == m_file->size()) { stopPlayback(); } else { if (QAudio::StoppedState == state) { // Check error QAudio::Error error = QAudio::NoError; switch (m_mode) { case QAudio::AudioInput: error = m_audioInput->error(); break; case QAudio::AudioOutput: error = m_audioOutput->error(); break; } if (QAudio::NoError != error) { reset(); return; } } setState(state); } }
//-------------------------------------------------------------- void testApp::startRecording() { // stop playback if running stopPlayback(); kinectRecorder.init(ofToDataPath("recording.dat")); bRecord = true; }
void PlaybackDialog::on_stopButton_clicked() { ui->playButton->setChecked(true); ui->recButton->setChecked(false); ui->fpsEdit->setText("100"); recording=false; emit stopPlayback(); }
void ofApp::keyPressed(int key) { if(key == ' ') { switch(mode) { case PREVIEW: stopPreview(); startRecord(); break; case RECORD: stopRecord(); startPlayback(); break; case PLAYBACK: stopPlayback(); startPreview(); break; } } }
void Engine::audioNotify() { switch (m_mode) { case QAudio::AudioInput: { const qint64 recordPosition = qMin(m_bufferLength, audioLength(m_format, m_audioInput->processedUSecs())); setRecordPosition(recordPosition); const qint64 levelPosition = m_dataLength - m_levelBufferLength; if (levelPosition >= 0) calculateLevel(levelPosition, m_levelBufferLength); if (m_dataLength >= m_spectrumBufferLength) { const qint64 spectrumPosition = m_dataLength - m_spectrumBufferLength; calculateSpectrum(spectrumPosition); } emit bufferChanged(0, m_dataLength, m_buffer); } break; case QAudio::AudioOutput: { const qint64 playPosition = audioLength(m_format, m_audioOutput->processedUSecs()); setPlayPosition(qMin(bufferLength(), playPosition)); const qint64 levelPosition = playPosition - m_levelBufferLength; const qint64 spectrumPosition = playPosition - m_spectrumBufferLength; if (m_file) { if (levelPosition > m_bufferPosition || spectrumPosition > m_bufferPosition || qMax(m_levelBufferLength, m_spectrumBufferLength) > m_dataLength) { m_bufferPosition = 0; m_dataLength = 0; // Data needs to be read into m_buffer in order to be analysed const qint64 readPos = qMax(qint64(0), qMin(levelPosition, spectrumPosition)); const qint64 readEnd = qMin(m_analysisFile->size(), qMax(levelPosition + m_levelBufferLength, spectrumPosition + m_spectrumBufferLength)); const qint64 readLen = readEnd - readPos + audioLength(m_format, WaveformWindowDuration); qDebug() << "Engine::audioNotify [1]" << "analysisFileSize" << m_analysisFile->size() << "readPos" << readPos << "readLen" << readLen; if (m_analysisFile->seek(readPos + m_analysisFile->headerLength())) { m_buffer.resize(readLen); m_bufferPosition = readPos; m_dataLength = m_analysisFile->read(m_buffer.data(), readLen); qDebug() << "Engine::audioNotify [2]" << "bufferPosition" << m_bufferPosition << "dataLength" << m_dataLength; } else { qDebug() << "Engine::audioNotify [2]" << "file seek error"; } emit bufferChanged(m_bufferPosition, m_dataLength, m_buffer); } } else { if (playPosition >= m_dataLength) stopPlayback(); } if (levelPosition >= 0 && levelPosition + m_levelBufferLength < m_bufferPosition + m_dataLength) calculateLevel(levelPosition, m_levelBufferLength); if (spectrumPosition >= 0 && spectrumPosition + m_spectrumBufferLength < m_bufferPosition + m_dataLength) calculateSpectrum(spectrumPosition); } break; } }
void eServiceHandlerDVB::gotMessage(const eDVRPlayerThreadMessage &message) { if (message.type == eDVRPlayerThreadMessage::done) { state=stateStopped; serviceEvent(eServiceEvent(eServiceEvent::evtEnd)); } else if (message.type == eDVRPlayerThreadMessage::liveeof) stopPlayback(1); }
static void processEvent(SDL_Event* e, InputContext* inputState, PlatformState* state) { ControllerInput* keyboardController = getContoller(inputState, 0); switch (e->type) { case SDL_QUIT: state->running = false; break; case SDL_WINDOWEVENT: processWindowEvent(&e->window); break; case SDL_KEYDOWN: case SDL_KEYUP: bool isDown = e->key.state == SDL_PRESSED; isDown &= e->key.state != SDL_RELEASED; if(e->key.repeat == 0) { switch(e->key.keysym.sym) { case SDLK_w: processKeyPress(&keyboardController->directionUp, isDown); break; case SDLK_s: processKeyPress(&keyboardController->directionDown, isDown); break; case SDLK_a: processKeyPress(&keyboardController->directionLeft, isDown); break; case SDLK_d: processKeyPress(&keyboardController->directionRight, isDown); break; case SDLK_l: //start/stop recording if(isDown && !state->isPlayingBack) { if(state->isRecording) { stopRecording(state); } else { beginRecording(state); } } break; case SDLK_p: //start/stop playback if(isDown && !state->isRecording) { if(state->isPlayingBack) { stopPlayback(state); *inputState = {}; } else { beginPlayback(state); } } break; } } break; } }
// ---------------------------------------------------------------------------- void AudioCoreDriver::deinitialize() // ---------------------------------------------------------------------------- { if (!mIsInitialized) return; stopPlayback(); AudioDeviceDestroyIOProcID(mDeviceID, mEmulationPlaybackProcID); AudioDeviceDestroyIOProcID(mDeviceID, mPreRenderedBufferPlaybackProcID); #if USE_NEW_API OSStatus err; AudioObjectPropertyAddress prop5 = { kAudioDevicePropertyStreamFormat, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; err = AudioObjectRemovePropertyListener(mDeviceID, &prop5, streamFormatChanged, (void*)this); if (err != kAudioHardwareNoError) printf("AudioObjectRemovePropertyListener(streamFormatChanged) failed\n"); AudioObjectPropertyAddress prop6 = { kAudioDeviceProcessorOverload, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; err = AudioObjectRemovePropertyListener(mDeviceID, &prop6, overloadDetected, (void*)this); if (err != kAudioHardwareNoError) printf("AudioObjectRemovePropertyListener(overloadDetected) failed\n"); AudioObjectPropertyAddress prop7 = { kAudioHardwarePropertyDefaultOutputDevice, kAudioDevicePropertyScopeOutput, kAudioObjectPropertyElementMaster }; err = AudioObjectRemovePropertyListener(mDeviceID, &prop7, deviceChanged, (void*)this); if (err != kAudioHardwareNoError) printf("AudioObjectRemovePropertyListener(deviceChanged) failed\n"); #else AudioDeviceRemovePropertyListener(mDeviceID, 0, false, kAudioDevicePropertyStreamFormat, streamFormatChanged); AudioDeviceRemovePropertyListener(mDeviceID, 0, false, kAudioDeviceProcessorOverload, overloadDetected); AudioHardwareRemovePropertyListener(kAudioHardwarePropertyDefaultOutputDevice, deviceChanged); #endif delete[] mSampleBuffer1; mSampleBuffer1 = NULL; delete[] mSampleBuffer2; mSampleBuffer2 = NULL; mSampleBuffer = NULL; mRetSampleBuffer = NULL; delete[] mSpectrumBuffer; mSpectrumBuffer = NULL; mIsInitialized = false; }
void MainWindow::fileOpen() { QFileDialog ofd(this, tr("Open ILDA file"), ""); ofd.setFileMode(QFileDialog::AnyFile); ofd.setFilter(tr("ILDA files (*.ild);;All files (*.*)")); ofd.setViewMode(QFileDialog::Detail); if (ofd.exec()) { QString fileName = ofd.selectedFiles().at(0); QFileInfo fileInfo(fileName); if (fileInfo.exists()) { ReaderWriterILDA reader; _sequence = QSharedPointer<Sequence>(reader.readFile(fileName)); _sequence->setPalette(*_currentPalette); // Fill file statistics fileNameLabel->setText(fileInfo.fileName()); fileSizeLabel->setText(getFileSize(fileInfo.size())); ildaFormatLabel->setText(reader.version()); numberOfFramesLabel->setText(QString::number(_sequence->frameCount())); // Set the current drawing mode (FIXME: Do not query the GUI for such infos) if (normalRadioButton->isChecked()) _sequence->setDrawMode(Sequence::DrawModeNormal); else if (diagnosticRadioButton->isChecked()) _sequence->setDrawMode(Sequence::DrawModeDiagnostic); // Setup frame slider frameSlider->setRange(0, _sequence->frameCount()-1); // Build the connections connect(_sequence.data(), SIGNAL(frameChanged(Frame*)), this, SLOT(frameChanged(Frame*))); connect(firstFrameButton, SIGNAL(clicked()), _sequence.data(), SLOT(gotoFirstFrame())); connect(lastFrameButton, SIGNAL(clicked()), _sequence.data(), SLOT(gotoLastFrame())); connect(stopButton, SIGNAL(clicked()), _sequence.data(), SLOT(stopPlayback())); connect(playButton, SIGNAL(clicked()), _sequence.data(), SLOT(startPlayback())); connect(frameSlider, SIGNAL(valueChanged(int)), _sequence.data(), SLOT(setActiveFrame(int))); connect(normalRadioButton, SIGNAL(clicked()), this, SLOT(drawModeChanged())); connect(diagnosticRadioButton, SIGNAL(clicked()), this, SLOT(drawModeChanged())); QGraphicsScene *scene = new QGraphicsScene(); scene->addItem(_sequence.data()); graphicsView->setScene(scene); // FIXME: Need to call this until a resize event happens. resizeEvent(NULL); }
int eServiceHandlerDVB::stop(int workaround) { eDVBServiceController *sapi=eDVB::getInstance()->getServiceAPI(); if (sapi) sapi->switchService(eServiceReferenceDVB()); #ifndef DISABLE_FILE if (!workaround) stopPlayback(); #endif return 0; }
void TMRpcm::play(SDFile myFile) { sdFile = myFile; if(speakerPin != lastSpeakPin) { setPin(); lastSpeakPin=speakerPin; } stopPlayback(); if(!wavInfo(myFile) ) { return; //verify its a valid wav file } if(myFile.isOpen()) { playing = 1; myFile.seekSet(44); //skip the header info for(int i=0; i<buffSize; i++) { buffer[0][i] = myFile.read(); } whichBuff = false; buffEmpty[0] = false; buffEmpty[1] = true; //if(pwmMode){resolution = 8;}else{resolution = 4;} resolution = 8; resolution = resolution * (1000000/SAMPLE_RATE); //Serial.println(resolution); volModMax = (resolution*1.5) / 248 ; volMod = constrain(volMod, 1, volModMax); //noInterrupts(); *ICRn[tt] = resolution; *OCRnA[tt] = *OCRnB[tt] = 1; //if(pwmMode){ *TCCRnA[tt] = _BV(WGM11) | _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1); //WGM11,12,13 all set to 1 = fast PWM/w ICR TOP *TCCRnB[tt] = _BV(WGM13) | _BV(WGM12) | _BV(CS10); // }else{ // Serial.println("A punto de comenzar a reproducir"); // *TCCRnA[tt] = _BV(COM1A1) | _BV(COM1B0) | _BV(COM1B1); // *TCCRnB[tt] = _BV(WGM13) | _BV(CS10); // } *TIMSK[tt] = ( _BV(ICIE1) | _BV(TOIE1) ); //interrupts(); } else { Serial.println("Read fail"); } }
void Engine::reset() { stopPlayback(); setState(QAudio::AudioInput, QAudio::StoppedState); setFormat(QAudioFormat()); m_generateTone = false; delete m_file; m_file = 0; delete m_analysisFile; m_analysisFile = 0; m_buffer.clear(); m_bufferPosition = 0; m_bufferLength = 0; m_dataLength = 0; emit dataLengthChanged(0); resetAudioDevices(); }
static int play( const char *url ) { cgmi_Status retStat = CGMI_ERROR_SUCCESS; void *pSessionId; // Start playback retStat = startPlayback(url, &pSessionId); CHECK_ERROR_RETURN_STAT(retStat); // Let it play for a few seconds. g_usleep(10 * 1000 * 1000); retStat = stopPlayback(pSessionId); CHECK_ERROR_RETURN_STAT(retStat); return retStat; }
VideoWindow::~VideoWindow() { #if (defined Q_OS_LINUX) && (QT_VERSION < 0x050000) //XXX IN PORT TO QT 5.1 THIS IS BROKEN CODE XXX // unembed vlc backend first x11Container->discardClient(); #endif stopPlayback(); /* No need to keep the media now */ if (m) libvlc_media_release (m); /* nor the player */ libvlc_media_player_release (mp); // unload vlc libvlc_release (inst); }
VideoWindow::~VideoWindow() { #ifdef Q_OS_LINUX // unembed vlc backend first x11Container->discardClient(); #endif stopPlayback(); /* No need to keep the media now */ if (m) libvlc_media_release (m); /* nor the player */ libvlc_media_player_release (mp); // unload vlc libvlc_release (inst); }
// ---------------------------------------------------------------------------- bool AudioCoreDriver::startPreRenderedBufferPlayback() // ---------------------------------------------------------------------------- { if (mInstanceId != 0) return false; if (!mIsInitialized) return false; stopPlayback(); mIsPlayingPreRenderedBuffer = true; memset(mSampleBuffer, 0, sizeof(short) * mNumSamplesInBuffer); AudioDeviceStart(mDeviceID, mPreRenderedBufferPlaybackProcID); return true; }
//////////////////////////////////////////////////////////////////////////////// // Verify section filters work as expected //////////////////////////////////////////////////////////////////////////////// static int secfil( const char *url ) { cgmi_Status retStat = CGMI_ERROR_SUCCESS; void *pSessionId; retStat = startPlayback(url, &pSessionId); CHECK_ERROR_RETURN_STAT(retStat); // Wait for playback to start and demux to be created g_usleep(2 * 1000 * 1000); retStat = verifySectionFilter(pSessionId); CHECK_ERROR_RETURN_STAT(retStat); retStat = stopPlayback(pSessionId); CHECK_ERROR_RETURN_STAT(retStat); return retStat; }
void eServiceHandlerDVB::startPlayback(const eString &filename, int livemode, bool startpaused) { stopPlayback(); decoder=new eDVRPlayerThread(filename.c_str(), this, livemode,playingPermanentTimeshift); if (startpaused) { decoder->messages.send(eDVRPlayerThread::eDVRPlayerThreadMessage(eDVRPlayerThread::eDVRPlayerThreadMessage::startPaused, livemode)); } else { decoder->messages.send(eDVRPlayerThread::eDVRPlayerThreadMessage(eDVRPlayerThread::eDVRPlayerThreadMessage::start, livemode)); } flags=flagIsSeekable|flagSupportPosition; state= statePlaying; if ( livemode ) flags|=flagStartTimeshift; pcrpid = Decoder::current.pcrpid; // stop pcrpid Decoder::parms.pcrpid = -1; Decoder::Set(); serviceEvent(eServiceEvent(eServiceEvent::evtFlagsChanged) ); if ( livemode ) flags&=~flagStartTimeshift; }
void TMRpcm::play(char* filename){ pinMode(speakerPin, OUTPUT); stopPlayback(); Serial.print("Playing: ");Serial.println(filename); if(!wavInfo(filename) ){ return; }//verify its a valid wav file if(sFile){sFile.close();} sFile = SD.open(filename); if(sFile){ // wavInfo(filename); //verify its a valid wav file sFile.seek(44); //skip the header info for(int i=0; i<buffSize; i++){ buffer[0][i] = sFile.read(); } whichBuff = false; buffEmpty[0] = false; buffEmpty[1] = true; startPlayback(); //Serial.println(cycles); }else{Serial.println("failed to open music file"); } }
void LLAgentPilot::updateTarget() { if (mPlaying) { if (mCurrentAction < mActions.count()) { if (0 == mCurrentAction) { if (gAgent.getAutoPilot()) { // Wait until we get to the first location before starting. return; } else { if (!mStarted) { llinfos << "At start, beginning playback" << llendl; mTimer.reset(); LLFrameStats::startLogging(NULL); mStarted = TRUE; } } } if (mTimer.getElapsedTimeF32() > mActions[mCurrentAction].mTime) { //gAgent.stopAutoPilot(); mCurrentAction++; if (mCurrentAction < mActions.count()) { gAgent.startAutoPilotGlobal(mActions[mCurrentAction].mTarget); } else { stopPlayback(); LLFrameStats::stopLogging(NULL); mNumRuns--; if (sLoop) { if ((mNumRuns < 0) || (mNumRuns > 0)) { llinfos << "Looping, restarting playback" << llendl; startPlayback(); } else if (mQuitAfterRuns) { llinfos << "Done with all runs, quitting viewer!" << llendl; LLAppViewer::instance()->forceQuit(); } else { llinfos << "Done with all runs, disabling pilot" << llendl; stopPlayback(); } } } } } else { stopPlayback(); } } else if (mRecording) { if (mTimer.getElapsedTimeF32() - mLastRecordTime > 1.f) { addAction(STRAIGHT); } } }
void ParticlePreview::setParticle(const std::string& name) { std::string nameClean = name; if (boost::algorithm::ends_with(nameClean, ".prt")) { nameClean = nameClean.substr(0, nameClean.length() - 4); } // If the model name is empty, release the model if (nameClean.empty()) { if (_particleNode) { _entity->removeChildNode(_particleNode); } _particleNode.reset(); stopPlayback(); return; } // Set up the scene if (!_entity) { setupSceneGraph(); } if (_particleNode) { _entity->removeChildNode(_particleNode); } // Construct the particle emitter node _particleNode = GlobalParticlesManager().createParticleNode(nameClean); if (_particleNode && _lastParticle != nameClean) { _entity->addChildNode(_particleNode); // Reset preview time stopPlayback(); // Reset the rotation to the default one _rotation = Matrix4::getRotation(Vector3(0,-1,0), Vector3(0,-0.3f,1)); _rotation.multiplyBy(Matrix4::getRotation(Vector3(0,1,0), Vector3(1,-1,0))); // Call update(0) once to enable the bounds calculation _particleNode->getParticle()->update(_rotation); // Use particle AABB to adjust camera distance const AABB& particleBounds = _particleNode->getParticle()->getBounds(); if (particleBounds.isValid()) { _camDist = -2.0f * static_cast<float>(particleBounds.getRadius()); } else { // Bounds not valid, fall back to default _camDist = -40.0f; } _lastParticle = nameClean; // Start playback when switching particles startPlayback(); } // Redraw queueDraw(); }
VideoWindow::VideoWindow(Context *context, const QDir &home) : GcWindow(context), home(home), context(context), m_MediaChanged(false) { setControls(NULL); setInstanceName("Video Window"); setProperty("color", Qt::black); QHBoxLayout *layout = new QHBoxLayout(); setLayout(layout); // config paramaters to libvlc const char * const vlc_args[] = { "-I", "dummy", /* Don't use any interface */ "--ignore-config", /* Don't use VLC's config */ "--disable-screensaver", /* disable screensaver during playback */ #ifdef Q_OS_LINUX "--no-xlib", // avoid xlib thread error messages #endif "--verbose=-1", // -1 = no output at all "--quiet" }; /* create an exception handler */ //libvlc_exception_init(&exceptions); //vlc_exceptions(&exceptions); /* Load the VLC engine */ inst = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); //vlc_exceptions(&exceptions); /* Create a new item */ m = NULL; //vlc_exceptions(&exceptions); /* Create a media player playing environement */ mp = libvlc_media_player_new (inst); //vlc_exceptions(&exceptions); //vlc_exceptions(&exceptions); /* This is a non working code that show how to hooks into a window, * if we have a window around */ #ifdef Q_OS_LINUX x11Container = new QX11EmbedContainer(this); layout->addWidget(x11Container); libvlc_media_player_set_xwindow (mp, x11Container->winId()); #endif #ifdef WIN32 container = new QWidget(this); layout->addWidget(container); libvlc_media_player_set_hwnd (mp, container->winId()); #endif connect(context, SIGNAL(stop()), this, SLOT(stopPlayback())); connect(context, SIGNAL(start()), this, SLOT(startPlayback())); connect(context, SIGNAL(pause()), this, SLOT(pausePlayback())); connect(context, SIGNAL(seek(long)), this, SLOT(seekPlayback(long))); connect(context, SIGNAL(unpause()), this, SLOT(resumePlayback())); connect(context, SIGNAL(mediaSelected(QString)), this, SLOT(mediaSelected(QString))); }
void TMRpcm::play(char* filename, unsigned long seekPoint){ if(speakerPin != lastSpeakPin){ #if !defined (MODE2) setPin(); #else setPins(); #endif lastSpeakPin=speakerPin; } stopPlayback(); if(!wavInfo(filename)){ #if defined (debug) Serial.println("WAV ERROR"); #endif return; }//verify its a valid wav file if(seekPoint > 0){ seekPoint = (SAMPLE_RATE*seekPoint) + fPosition(); seek(seekPoint); //skip the header info } playing = 1; bitClear(optionByte,7); //paused = 0; if(SAMPLE_RATE > 45050 ){ SAMPLE_RATE = 24000; #if defined (debug) Serial.print("SAMPLE RATE TOO HIGH: "); Serial.println(SAMPLE_RATE); #endif } #if !defined (USE_TIMER2) //if(qual) if(bitRead(optionByte,6)){resolution = 10 * (800000/SAMPLE_RATE);} else{ resolution = 10 * (1600000/SAMPLE_RATE); } #else resolution = 255; if(SAMPLE_RATE < 9000){ *TCCRnB[tt] &= ~_BV(CS20); *TCCRnB[tt] |= _BV(CS21); }else{ *TCCRnB[tt] &= ~_BV(CS21); *TCCRnB[tt] |= _BV(CS20); } #endif byte tmp = (sFile.read() + sFile.peek()) / 2; #if defined(rampMega) if(bitRead(optionByte,5)){ *OCRnA[tt] = 0; *OCRnB[tt] = resolution; timerSt(); for(unsigned int i=0; i < resolution; i++){ *OCRnB[tt] = constrain(resolution-i,0,resolution); //if(bitRead(*TCCRnB[tt],0)){ // for(int i=0; i<10; i++){ // while(*TCNT[tt] < resolution-50){} // } //}else{ delayMicroseconds(150); //} } } bitClear(optionByte,5); #endif //rampUp = 0; unsigned int mod; if(volMod > 0){ mod = *OCRnA[tt] >> volMod; }else{ mod = *OCRnA[tt] << (volMod*-1); }