void En2DSound::handleNotification( const yaf3d::EntityNotification& notification )
{
    // handle menu entring / leaving
    switch( notification.getId() )
    {
        case YAF3D_NOTIFY_MENU_ENTER:

            stopPlaying( true );
            break;

        case YAF3D_NOTIFY_MENU_LEAVE:

            // respond to sound setting changes in menu only if the sound type is not Common
            if ( yaf3d::SoundManager::get()->getSoundGroupIdFromString( _soundGroup ) != yaf3d::SoundManager::SoundGroupCommon )
                setupSound();

            startPlaying( true );
            break;

        case YAF3D_NOTIFY_ENTITY_ATTRIBUTE_CHANGED:
        {
            // recreate sound if any attribute has been changed
            if (  _soundID > 0 )
            {
                try
                {
                    stopPlaying( false );
                    yaf3d::SoundManager::get()->releaseSound( _soundID );
                    _soundID = 0;
                }
                catch ( const yaf3d::SoundException& )
                {
                }
            }
            setupSound();
        }
        break;

        case YAF3D_NOTIFY_UNLOAD_LEVEL:
        {
            // nothing to do atm
        }
        break;

        default:
            ;
    }
}
示例#2
0
void DynamicStimulusDriver::stop() {
	boost::mutex::scoped_lock locker(stim_lock);
    
    if (isPlaying()) {
        stopPlaying();
    }
}
示例#3
0
// Present the next frame due when playing back.
// Used by the playback timer class.
void recording::nextFrameDue()
{
    int currentFrame = ui->horizontalSliderPosition->value();
    showRecordedFrame( currentFrame );

    // If done all frames, loop if looping, otherwise stop
    if( ui->horizontalSliderPosition->value() == ui->horizontalSliderPosition->maximum() )
    {
        if( ui->checkBoxLoop->isChecked() )
        {
            ui->horizontalSliderPosition->setValue( 0 );
        }
        else
        {
            stopPlaying();
        }
    }

    // If not done all frames, step on to the next
    else
    {
        ui->horizontalSliderPosition->setValue( currentFrame+1 );
    }

    // Set the due time for the next frame
    timer->setInterval( ui->doubleSpinBoxPlaybackRate->value() * 1000 );
}
示例#4
0
文件: FileSink.cpp 项目: ares89/vlc
void FileSink::afterGettingFrame(unsigned frameSize,
				 unsigned numTruncatedBytes,
				 struct timeval presentationTime) {
  if (numTruncatedBytes > 0) {
    envir() << "FileSink::afterGettingFrame(): The input frame data was too large for our buffer size ("
	    << fBufferSize << ").  "
            << numTruncatedBytes << " bytes of trailing data was dropped!  Correct this by increasing the \"bufferSize\" parameter in the \"createNew()\" call to at least "
            << fBufferSize + numTruncatedBytes << "\n";
  }
  addData(fBuffer, frameSize, presentationTime);

  if (fOutFid == NULL || fflush(fOutFid) == EOF) {
    // The output file has closed.  Handle this the same way as if the
    // input source had closed:
    onSourceClosure(this);

    stopPlaying();
    return;
  }

  if (fPerFrameFileNameBuffer != NULL) {
    if (fOutFid != NULL) { fclose(fOutFid); fOutFid = NULL; }
  }

  // Then try getting the next frame:
  continuePlaying();
}
示例#5
0
void CDROM::startTrack(const char *trackName) {
	if (!_LICbuffer)
		return;

	byte *matchPtr = getTrackBuffer(trackName);
	if (!matchPtr) {
		warning("CDROM: Track \"%s\" not found", trackName);
		return;
	}

	strncpy0(_curTrack, trackName, 15);

	stopPlaying();
	_curTrackBuffer = matchPtr;

	while (getTrackPos() >= 0)
		;

	uint32 start = READ_LE_UINT32(matchPtr + 12);
	uint32 end   = READ_LE_UINT32(matchPtr + 16);

	play(start, end);

	_startTime = g_system->getMillis();
	_trackStop = _startTime + (end - start + 1 + 150) * 40 / 3;
}
示例#6
0
/**
 * Play back specified file.
 *
 * @param file
 *        file path.
 * @return
 *        0 if file playback started, 1 if output was locked, other values on errors.
 */
int
SrvPlayFile( const char * file )
{
	int status;
	
	stopServer();
	
	LOCK_PLAYMUTEX();
	strcpy(trackName, file);
	playtype = NPT_FILE;
	going = 1;
	everPlayed = 0;
	UNLOCK_PLAYMUTEX();

	status = playFile(file);
	if (status) stopPlaying();
	else
	{
		LOCK_PLAYMUTEX();
		playState = NMS_STATUS_PLAYER_PLAY; 
		errorStatus = NMS_STATUS_OK;
		UNLOCK_PLAYMUTEX();
	}
	return status;
}
示例#7
0
void recording::on_radioButtonLive_toggled( bool checked )
{
    // If going to live mode, ensure no longer playing
    if( checked )
    {
        if( ui->pushButtonPlay->isChecked() )
        {
            stopPlaying();
        }
    }

    // If going to playback mode, ensure no longer recording
    else
    {
        if( ui->pushButtonRecord->isChecked() )
        {
            ui->pushButtonRecord->setChecked( false );
        }
        ui->horizontalSliderPosition->setMaximum( history.count()-1 );

        on_pushButtonFirstImage_clicked();
    }

    // Enable appropriate controls (playback or record)
    ui->groupBoxLive->setVisible( ui->radioButtonLive->isChecked() );
    ui->groupBoxPlayback->setVisible( !ui->radioButtonLive->isChecked() );

    // Signal to the QEImage that recorder is in playback or record mode
    emit playingBack( !checked );
}
示例#8
0
T140TextRTPSink::~T140TextRTPSink() {
  fSource = fOurIdleFilter; // hack: in case "fSource" had gotten set to NULL before we were called
  stopPlaying(); // call this now, because we won't have our 'idle filter' when the base class destructor calls it later.

  // Close our 'idle filter' as well:
  Medium::close(fOurIdleFilter);
  fSource = NULL; // for the base class destructor, which gets called next
}
void DialogVideoPlayer::playButtonPress() {

    if (playing) {
        stopPlaying();
    } else {
        startPlaying();
    }
}
示例#10
0
int processEvent(GameEvent* e) {
  int value = 0;
  Data *data;

  if(game2->mode == GAME_SINGLE_RECORD) {
    writeEvent(e);
  }
  switch(e->type) {
  case EVENT_TURN_LEFT:
    data = game->player[e->player].data;
    if(data->speed > 0) {
      data->iposx = e->x;
      data->iposy = e->y;
      data->turn = TURN_LEFT;
      doTurn(data, e->timestamp);
    }
    break;
  case EVENT_TURN_RIGHT:
    data = game->player[e->player].data;
    if(data->speed > 0) {
      data->iposx = e->x;
      data->iposy = e->y;
      data->turn = TURN_RIGHT;
      doTurn(data, e->timestamp);
    }
    break;
  case EVENT_CRASH: 
    data = game->player[e->player].data;
    data->posx = data->iposx = e->x;
    data->posy = data->iposy = e->y;
    sprintf(messages, "player %d crashed", e->player + 1);
    fprintf(stderr, "%s\n", messages);
    consoleAddLine(messages);
    crashPlayer(e->player);
    break;
  case EVENT_STOP:
    fprintf(stderr, "game stopped\n");
    if(game2->mode == GAME_SINGLE_RECORD) {
      stopRecording();
      game2->mode = GAME_SINGLE;
    } else if(game2->mode == GAME_PLAY) {
      stopPlaying();
      game2->mode = GAME_SINGLE;
    }
    game->winner = e->player;
    sprintf(messages, "winner: %d", game->winner + 1);
    printf("%s\n", messages);
    consoleAddLine(messages);
    switchCallbacks(&pauseCallbacks);
    /* screenSaverCheck(0); */
    stoptime = SystemGetElapsedTime();
    game->pauseflag = PAUSE_GAME_FINISHED;
    value = 1;
    break;
  }
  free(e);
  return value;
}
示例#11
0
LinVideoDisplayForm::~LinVideoDisplayForm()
{
  stopPlaying();

//  if (fullScreenButton) delete fullScreenButton;
  if (dataDialog) delete dataDialog;

  delete ui;
}
H264or5VideoRTPSink::~H264or5VideoRTPSink() {
  fSource = fOurFragmenter; // hack: in case "fSource" had gotten set to NULL before we were called
  delete[] fFmtpSDPLine;
  delete[] fVPS; delete[] fSPS; delete[] fPPS;
  stopPlaying(); // call this now, because we won't have our 'fragmenter' when the base class destructor calls it later.

  // Close our 'fragmenter' as well:
  Medium::close(fOurFragmenter);
  fSource = NULL; // for the base class destructor, which gets called next
}
void DialogVideoPlayer::changeMovieMode() {
    stopPlaying();
    if (!ui->checkBoxMovie->isChecked()) {
        paintBackgroundImage();
        ui->labelTimeOffset->setEnabled(false);
        ui->spinBoxTimeOffset->setEnabled(false);
    } else {
        clearBackgroundImage();
        ui->labelTimeOffset->setEnabled(true);
        ui->spinBoxTimeOffset->setEnabled(true);
    }
}
示例#14
0
void LinVideoDisplayForm::closeEvent(
  QCloseEvent *event)
{
  QWidget::closeEvent(event);

  stopPlaying();

  // Set landscape orientation to false:
  parentWidget()->setAttribute(static_cast<Qt::WidgetAttribute>(129), false);
  // Set auto orientation to true:
  parentWidget()->setAttribute(static_cast<Qt::WidgetAttribute>(130), true);
}
 void SimpleSource::startPlayingImpl(Timestamp start) throw(Exception)
 {
     // If it's playing, must stop and restart - cannot simply play again.
     if (isPlaying())
         stopPlaying();
     
     setLastKnownPlayingTime(start);
     playing = true;
     
     if (getScene())
         getScene()->notifySourcePlaying(shared_from_this(), true);
 }
示例#16
0
void LAudioAppComponent::shutdownAudio() {
    stopPlaying();
    if(!audioOpen)return;
    if(audioSourcePlayer.getCurrentSource()!=nullptr) {
        audioSourcePlayer.setSource (nullptr);
    }
    if(audioOpen) {
        deviceManager.removeAudioCallback (&audioSourcePlayer);
        deviceManager.closeAudioDevice();
    }
    audioOpen = false;
}
void DialogVideoPlayer::startPlaying() {
    qDebug() << "Start Playing";
    resizeDisplay();
    playing = true;
    ui->buttonPlay->setIcon(style()->standardIcon(QStyle::SP_MediaPause));
    if (ui->checkBoxMovie->isChecked()) {
        if (mediaPlayer->mediaStatus() == QMediaPlayer::InvalidMedia) {
            ui->checkBoxMovie->setChecked(false);
            ui->checkBoxMovie->setEnabled(false);
            stopPlaying();
            return;
        }

        while(mediaPlayer->mediaStatus() == QMediaPlayer::LoadingMedia) {
            qApp->processEvents();
        }

        mediaPlayer->setPosition(currentTimeMS + movieOffsetMS - firstSampleMS);
        mediaPlayer->play();

        while(mediaPlayer->state() == QMediaPlayer::PlayingState && playing) {

            // Get position in ms with offset since start of movie and map to data
            double current_movie_time = (double)(mediaPlayer->position()) + firstSampleMS - movieOffsetMS;
            updatePlaybackStateTime(current_movie_time);
            qApp->processEvents();
        }
        stopPlaying();
        mediaPlayer->pause();
    } else {
        clockStartTime = getMilliCount();
        playStartSampleMS = p_roughM->at(qMax(0, currentIndex), 0 );
        while(playing) {
            double current_movie_time = playStartSampleMS + getMilliCount() - clockStartTime;
            updatePlaybackStateTime(current_movie_time);
            qApp->processEvents();
        }
        stopPlaying();
    }
}
void ScreenTab::startStopPlaying()
{
    qDebug() << "Start or stop playing...";
    if (!_desktopMediaPlayer)
        return;
    if (!_desktopMediaPlayer->isShowed())
    {
        startPlaying();
    } else
    {
        stopPlaying();
        ui->mediaPreview->setScene(NULL);
    }
}
示例#19
0
void recording::on_pushButtonPlay_toggled(bool checked)
{
    // Set icon and stop or start playback
    if( checked )
    {
        ui->pushButtonPlay->setIcon( *pauseIcon );
        startPlaying();
    }
    else
    {
        ui->pushButtonPlay->setIcon( *playIcon );
        stopPlaying();
    }
}
ScreenTab::ScreenTab(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::ScreenTab),
    _currentMedia(NULL),
    _screen(NULL),
    _desktopMediaPlayer(new DesktopMediaPlayer(this))
{
    ui->setupUi(this);
    setScreen(new Screen(this));

//    ui->currentDisplaySpinBox->setMaximum(QApplication::desktop()->screenCount() - 1);

    ui->splitter->setStretchFactor(0, 1);
    ui->splitter->setSizes(QList<int>() << 10000 << 1);
    setContextMenuPolicy(Qt::PreventContextMenu);

    addAction(ui->actionStartStopPlaying);

    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::FilePatch, QHeaderView::Stretch);
    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::NumberToShow, QHeaderView::ResizeToContents);
    ui->mediaListTableView->horizontalHeader()->setResizeMode(MediaTableModel::RandomWeigth, QHeaderView::ResizeToContents);
    ui->mediaListTableView->addAction(ui->actionAddMedia);
    ui->mediaListTableView->addAction(ui->actionAddExtension);
    ui->mediaListTableView->addAction(ui->actionRemoveRow);
    ui->mediaListTableView->addAction(ui->actionMoveMediaUp);
    ui->mediaListTableView->addAction(ui->actionMoveMediaDown);
    ui->mediaListTableView->setContextMenuPolicy(Qt::ActionsContextMenu);
    connect(ui->actionAddMedia, SIGNAL(triggered()), this, SLOT(addMedia()));
    connect(ui->actionAddExtension, SIGNAL(triggered()), this, SLOT(addExtension()));
    connect(ui->actionRemoveRow, SIGNAL(triggered()), this, SLOT(removeMedia()));
    connect(ui->actionMoveMediaUp, SIGNAL(triggered()), this, SLOT(moveMediaUp()));
    connect(ui->actionMoveMediaDown, SIGNAL(triggered()), this, SLOT(moveMediaDown()));
    connect(ui->actionStartStopPlaying, SIGNAL(triggered()), this, SLOT(startStopPlaying()));
    connect(ui->actionSave, SIGNAL(triggered()), this, SLOT(save()));
    connect(ui->actionLoad, SIGNAL(triggered()), this, SLOT(load()));

//    connect(ui->currentDisplaySpinBox, SIGNAL(valueChanged(int)), this, SLOT(onCurrentDisplaySpinBoxChanged(int)));

    connect(_desktopMediaPlayer, SIGNAL(graphicSceneChanged(QGraphicsScene*)), this, SLOT(setSceneToPreview(QGraphicsScene*)));
    connect(_desktopMediaPlayer, SIGNAL(escKeyPressed()), this, SLOT(stopPlaying()));

    mediaListSelectedChanded(QItemSelection(), QItemSelection());

    //Законектим изменение данных в энжайне расширений со слотом обновления расширений
    connect(MDVPlayerApplication::instance(), SIGNAL(extensionEngineDataChanged()), this, SLOT(updateExtensions()));

    onCurrentDisplaySpinBoxChanged(1);
//    onCurrentDisplaySpinBoxChanged(ui->currentDisplaySpinBox->value());
}
示例#21
0
文件: Player.cpp 项目: DaveDubUK/hifi
void Player::setCurrentFrame(int currentFrame) {
    if (_recording && currentFrame >= _recording->getFrameNumber()) {
        stopPlaying();
        return;
    }
    
    _currentFrame = currentFrame;
    _timerOffset = _recording->getFrameTimestamp(_currentFrame);
    
    if (isPlaying()) {
        _timer.start();
        setAudioInjectorPosition();
    } else {
        _pausedFrame = _currentFrame;
    }
}
示例#22
0
文件: event.c 项目: Zoxc/gltron
int processEvent(GameEvent* e) {
  int value = 0;

#ifdef RECORD
  if(game2->mode == GAME_SINGLE_RECORD) {
    writeEvent(e);
  }
#endif
  switch(e->type) {
  case EVENT_TURN_LEFT:
    doTurn(e, TURN_LEFT);
    break;
  case EVENT_TURN_RIGHT:
    doTurn(e, TURN_RIGHT);
    break;
  case EVENT_CRASH: 
    displayMessage(TO_CONSOLE, "player %d crashed", e->player + 1);
    doCrashPlayer(e);
    break;
  case EVENT_STOP:
    // displayMessage(TO_STDOUT, "game stopped");
#ifdef RECORD
    if(game2->mode == GAME_SINGLE_RECORD) {
      stopRecording();
      game2->mode = GAME_SINGLE;
    } else if(game2->mode == GAME_PLAY) {
      stopPlaying();
      game2->mode = GAME_SINGLE;
    }
#endif
    if(e->player<PLAYERS && game->player[e->player].ai->active != AI_NONE) {
      game->winner = e->player;
      displayMessage(TO_CONSOLE, "winner: %d", game->winner + 1);
    } else {
      game->winner = -2;
      displayMessage(TO_CONSOLE, "everyone died! no one wins!");
    }
		SystemExitLoop(RETURN_GAME_END);
    game->pauseflag = PAUSE_GAME_FINISHED;
    value = 1;
    break;
  }
  free(e);
  return value;
}
示例#23
0
int Player::startPlaying(){
    if (playing) {
        stopPlaying();
    }
    time(&playbackStartingTime);
    filePtr = sf_open(destPath, SFM_READ, &fileInfo); //Opens file with info from init_sndfile()
    //printLog(*new std::string("* Opened File ") + destPath);
    PaError err;
    err = Pa_StartStream( stream ); //Start the input stream
    //printLog("* Stream started");
    if( err != paNoError ){
        printPaError(err);
        return -1;
    }
    playing = true; //set playing bool. This helps external classes to decide if the player is running or not.
    worker = new std::thread(playbackThread, stream, sampleBlock, filePtr, &stopPlaybackThread, &stopPlaybackThread_mutex, &playbackThreadFinishedPlaying, &playbackThreadFinishedPlaying_mutex);
    return 0;
}
示例#24
0
void GuiPlay::executeRound()
{
  if ( timerCount_ < game_.getIterations() ) {
    game_.executeRound();
    bool updateScore = timerCount_ % 500 == 0 ||
                       timerCount_ == game_.getIterations() - 1;
    if ( timerCount_ % updateFrequency_ == 0 ) {
      runRound( game_.minScore(), game_.maxScore(), updateScore );
    }
    ++timerCount_;
    progressBar_->setValue( timerCount_ );
  } else {
    timeBetweenRounds_->stop();
    paused_ = false;
    stopped_ = true;
    emit stopPlaying();
  }
}
void Display::OnStop()
{
	
	if(isstart)
	return;
	
	if(doit==TRUE)
	talk->Stop();

	stopRecording();
	stopPlaying();
	selectflag=0;


	//change state
	isstart=1;
	start->ShowWindow(TRUE);
	stop->ShowWindow(FALSE);
}
示例#26
0
void AudioPlayback::startPlaying(QIODevice * stream)
{
    qDebug() << "AudioPlayback::startPlaying";

    m_audioOutput = new QAudioOutput(m_format);
    connect(m_audioOutput,SIGNAL(stateChanged(QAudio::State)),SLOT(printState(QAudio::State)));

    m_stream = stream;
    connect(m_stream, SIGNAL(aboutToClose()), this, SLOT(stopPlaying()));
//    connect(stream, SIGNAL(readyRead()), this, SLOT(processIncomingData()), Qt::DirectConnection);

    // Open IODevice if not open already
    if(!stream->isOpen())
    {
        stream->open(QIODevice::ReadOnly);
    }

    m_audioOutput->start(m_stream);
}
示例#27
0
void FileSink::afterGettingFrame1(unsigned frameSize,
				  struct timeval presentationTime) {
  addData(fBuffer, frameSize, presentationTime);

  if (fOutFid == NULL || fflush(fOutFid) == EOF) {
    // The output file has closed.  Handle this the same way as if the
    // input source had closed:
    onSourceClosure(this);

    stopPlaying();
    return;
  }
 
  if (fPerFrameFileNameBuffer != NULL) {
    if (fOutFid != NULL) { fclose(fOutFid); fOutFid = NULL; }
  }

  // Then try getting the next frame:
  continuePlaying();
}
示例#28
0
void TourWidgetPrivate::updateRootIndex()
{
    GeoDataTour *tour = findTour( m_document );
    if ( tour ){
        GeoDataPlaylist *playlist = tour->playlist();
        if ( playlist ) {
            m_tourUi.m_listView->setModel( m_widget->model()->treeModel() );
            m_tourUi.m_listView->setRootIndex( m_widget->model()->treeModel()->index( playlist ) );
            QObject::connect( m_tourUi.m_listView->selectionModel(), SIGNAL( selectionChanged( QItemSelection, QItemSelection ) ),
                              q, SLOT( updateButtonsStates() ) );
        }
        m_playback.setMarbleWidget( m_widget );
        m_playback.setTour( tour );
        m_tourUi.m_slider->setMaximum( m_playback.duration() * 100 );
        QTime nullTime( 0, 0, 0 );
        QTime time = nullTime.addSecs( m_playback.duration() );
        m_tourUi.m_totalTime->setText( QString("%L1:%L2").arg( time.minute(), 2, 10, QChar('0') ).arg( time.second(), 2, 10, QChar('0') ) );
        QObject::connect( &m_playback, SIGNAL( progressChanged( double ) ),
                         q, SLOT( handlePlaybackProgress( double ) ) );
        q->stopPlaying();
        m_tourUi.m_toolBarPlayback->setEnabled( true );
        bool isPlaybackEmpty = m_playback.mainTrackSize() != 0;
        m_tourUi.actionPlay->setEnabled( isPlaybackEmpty );
        m_tourUi.m_slider->setEnabled( isPlaybackEmpty );
        m_tourUi.m_actionRecord->setEnabled( isPlaybackEmpty );
        m_tourUi.actionStop->setEnabled( false );
        if( m_playback.mainTrackSize() > 0 ) {
            if( dynamic_cast<PlaybackFlyToItem*>( m_playback.mainTrackItemAt( 0 ) ) ) {
                QModelIndex playlistIndex = m_widget->model()->treeModel()->index( playlist );
                for( int i = 0; i < playlist->size(); ++i ) {
                    if( playlist->primitive( i )->nodeType() == GeoDataTypes::GeoDataFlyToType ) {
                        m_delegate->setFirstFlyTo( m_widget->model()->treeModel()->index( i, 0, playlistIndex ) );
                        break;
                    }
                }
            } else {
                m_delegate->setFirstFlyTo( QPersistentModelIndex() );
            }
        }
    }
}
示例#29
0
Ibex::VLCVideoPlayer::~VLCVideoPlayer() {
  stopCapturing();
  stopPlaying();

  if(mp) {
    // Stop stream and clean up libVLC.
	while(libvlc_media_player_get_state(mp) != libvlc_Stopped) {
		libvlc_media_player_stop(mp);
	}
    libvlc_media_player_release(mp);
	mp = 0;
  }
  if(libvlc) {
    libvlc_release(libvlc);
	libvlc = 0;
  }
  if(context) {
	  delete context;
	  context = 0;
  }
}
示例#30
0
static void
stopServer( void )
{
	DBGMSG("stopping playback server");
	
	LOCK_PLAYMUTEX();
	going = 0;		
	preloaded = 1;
	// quit the nextfile thread first.
	trackChange = TC_NORMAL;
	UNLOCK_PLAYMUTEX();
	
	pthread_cond_broadcast(&nextFileCond);
	
	if (nextFileThread)
	{
		DBGMSG("Removing Next file thread!");
		pthread_join(nextFileThread, NULL);
		nextFileThread = (pthread_t)NULL;
		DBGMSG("Next file Thread removed!");
	}

	if (dirInitThread)
	{
		DBGMSG("Removing Init thread!");
		pthread_join(dirInitThread, NULL);
		dirInitThread = (pthread_t)NULL;
		DBGMSG("Init Thread removed!");
	}

	LOCK_PLAYMUTEX();
	dirInited = 0;
	UNLOCK_PLAYMUTEX();
	
	stopPlaying();
	
	LOCK_PLAYMUTEX();
	trackChange = TC_DISABLE;
	UNLOCK_PLAYMUTEX();
}