void QOpenSLESAudioOutput::destroyPlayer()
{
    if (m_state != QAudio::StoppedState)
        stopPlayer();

    if (m_playerObject) {
        (*m_playerObject)->Destroy(m_playerObject);
        m_playerObject = Q_NULLPTR;
    }

    if (m_outputMixObject) {
        (*m_outputMixObject)->Destroy(m_outputMixObject);
        m_outputMixObject = Q_NULLPTR;
    }

    if (!m_pullMode && m_audioSource) {
        m_audioSource->close();
        delete m_audioSource;
        m_audioSource = Q_NULLPTR;
    }

    delete [] m_buffers;
    m_buffers = Q_NULLPTR;
    m_processedBytes = 0;
    m_nextBuffer = 0;
    m_availableBuffers.storeRelease(BUFFER_COUNT);
    m_playItf = Q_NULLPTR;
    m_volumeItf = Q_NULLPTR;
    m_bufferQueueItf = Q_NULLPTR;
    m_startRequiresInit = true;
}
Beispiel #2
0
int DM_Music_PlayFile(const char *filename, int looped)
{
    if(!filename) return false;

    if(!fluid_is_midifile(filename))
    {
        // It doesn't look like MIDI.
        App_Log(DE2_LOG_VERBOSE, "[FluidSynth] Cannot play \"%s\": not a MIDI file", filename);
        return false;
    }

    if(sfontId < 0)
    {
        App_Log(DE2_LOG_VERBOSE, "[FluidSynth] Cannot play \"%s\" without an SF2 soundfont", filename);
        return false;
    }

    // If we are playing something, make sure it's stopped.
    stopPlayer();

    DENG_ASSERT(fsPlayer == NULL);

    // Create a new player.
    fsPlayer = new_fluid_player(DMFluid_Synth());
    fluid_player_add(fsPlayer, filename);
    fluid_player_set_loop(fsPlayer, looped? -1 /*infinite times*/ : 1);
    fluid_player_play(fsPlayer);

    startPlayer();

    DSFLUIDSYNTH_TRACE("PlayFile: playing '" << filename << "' using player "
                       << fsPlayer << " looped:" << looped << " sfont:" << sfontId);
    return true;
}
Beispiel #3
0
void JVlibForm::on_System_PauseMidi_button_toggled(bool checked)
{
  unsigned int current_tick;
  if (checked) {
      stopPlayer();
      if (seqTimer->isActive()) {
            disconnect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
            seqTimer->stop();
      }
        snd_seq_get_queue_status(seq, queue, status);
	current_tick = snd_seq_queue_status_get_tick_time(status);
        snd_seq_stop_queue(seq,queue,NULL);
        snd_seq_drain_output(seq);
	stop_sound();
	disconnect_port();
        System_PauseMidi_button->setText("Resume");
  }
  else {
	connect_port();
        snd_seq_continue_queue(seq, queue, NULL);
        snd_seq_drain_output(seq);
        snd_seq_get_queue_status(seq, queue, status);
	current_tick = snd_seq_queue_status_get_tick_time(status);
        System_PauseMidi_button->setText("Pause");
        connect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
	startPlayer(current_tick);
        seqTimer->start(100);
  }
}   // end on_System_PauseMidi_button_toggled
void QOpenSLESAudioOutput::stop()
{
    if (m_state == QAudio::StoppedState)
        return;

    stopPlayer();
    setError(QAudio::NoError);
}
void KNMusicBackendQtAVThread::stop()
{
    //Stop the player.
    stopPlayer();
    //Update the position as soon as possible.
    emit positionChanged(m_startPosition);
    //Emit the state changed signal.
    emit stateChanged(m_status);
}
Beispiel #6
0
void Phone::checkSound()
{
//	qWarning(QString("Phone::checkSound() - call_number = %1").arg(call_number));
	if (--call_number <= 0)
	{
		call_number = 0;
		stopRecorder();
		timer->stop();
		stopPlayer();
	}
}
Beispiel #7
0
void Player::desacceleratePlayer(){
	if(this->movement.x > 0 && !this->moving){
		this->movement.x -= this->desaccelerationX;
	}
	if(this->movement.x < 0 && !this->moving){
		this->movement.x += this->desaccelerationX;
	}
	if((this->movement.x > 0 && this->movement.x < 0.2) || (this->movement.x < 0 && this->movement.x > -0.2)){
		stopPlayer();
	}
}
void KNMusicBackendQtAVThread::reset()
{
    //Stop the player.
    stopPlayer();
    //Unload the data.
    m_player->unload();
    //Reset the position value.
    m_startPosition=-1;
    m_endPosition=-1;
    //Emit the state changed signal.
    emit stateChanged(m_status);
}
void KNMusicBackendQtAVThread::onActionPositionChanged(const qint64 &position)
{
    //Emit the position changed signal.
    emit positionChanged(position-m_startPosition);
    //Check whether the position reach the end position.
    if(position>=m_endPosition)
    {
        //Stop the player.
        stopPlayer();
        //Emit a finished signal.
        emit finished();
    }
}
//--------------------------------------------------------------
void pmWarpPiRendererVideoPlayer::onComplete(float* arg)
{
    // this function is called on when the tween is complete //
    //cout << "screen :: onComplete : arg = " << *arg << endl;
    
    if(arg == &screenOpacity.get())
    {
        //cout << "this is a stop?" << endl;
        if(screenOpacity==0.0) stopPlayer();
    }
    
    isFading = false;
}
Beispiel #11
0
void Phone::disablePlayer(bool on)
{
	if (on)
	{
		stopPlayer();
		play_status = PLAYER_STATUS_MUTE;
	}
	else
	{
		play_status = PLAYER_STATUS_STOP;
		if (call_number > 0)
		{
			startPlayer();
		}
	}
}
Beispiel #12
0
void DMFluid_Shutdown(void)
{
    if(!blockBuffer) return;

    stopPlayer();

    delete blockBuffer; blockBuffer = 0;

    if(fsPlayer)
    {
        delete_fluid_player(fsPlayer);
        fsPlayer = 0;
    }

    DSFLUIDSYNTH_TRACE("Music_Shutdown.");
}
Beispiel #13
0
void JVlibForm::on_System_PlayMidi_button_toggled(bool checked) {
    if (checked) {
	seqTimer = new QTimer(this);
        System_PauseMidi_button->setEnabled(true);
        System_OpenMidi_button->setEnabled(false);
        System_PlayMidi_button->setText("Stop");
	System_MIDI_progressBar->setEnabled(true);
        connect_port();
        // queue won't actually start until it is drained
        int err = snd_seq_start_queue(seq, queue, NULL);
        check_snd("start queue", err);
	System_PlayMidi_status->on();
        connect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
        seqTimer->start(100);
	startPlayer(0);
    }
    else {
        if (seqTimer->isActive()) {
            disconnect(JVlibForm::seqTimer, SIGNAL(timeout()), this, SLOT(tickDisplay()));
            seqTimer->stop();
	    delete seqTimer;
        }
        snd_seq_stop_queue(seq,queue,NULL);
        snd_seq_drain_output(seq);
	stopPlayer();
	stop_sound();
        disconnect_port();
	System_PlayMidi_status->off();
	System_MIDI_progressBar->blockSignals(true);
        System_MIDI_progressBar->setValue(0);
	System_MIDI_progressBar->blockSignals(false);
        MIDI_time_display->setText("00:00");
        if (System_PauseMidi_button->isChecked()) {
            System_PauseMidi_button->blockSignals(true);
            System_PauseMidi_button->setChecked(false);
            System_PauseMidi_button->blockSignals(false);
            System_PauseMidi_button->setText("Pause");
        }
        System_PauseMidi_button->setEnabled(false);
        System_PlayMidi_button->setText("Play");
        System_OpenMidi_button->setEnabled(true);
	System_MIDI_Transpose->setEnabled(true);
	System_MIDI_progressBar->setEnabled(false);
	event_num=0;
    }
}   // end on_System_PlayMidi_button_toggled
Beispiel #14
0
void onEvent(EventCode ec) {
    switch (ec) {
    case EV_STOP:
        if (playflag == true || pauseflag == true)
            stopPlayer();
        break;

    case EV_PLAY_PAUSE:
        if (playflag == true) pausePlayer();
        else if (pauseflag == true) resumePlayer();
        else startPlayer();
        break;

    default:
        break;
    }
}
void LadybugPlayerThread::run()
{
  // fill in a buffer with loaded, decoded frames
  // when full: sleep

  LadybugImage image;

  while (!shouldStop())
  {
    mStreamMutex.lock();
    bool res = mStream.readNextFrame(image);
    mStreamMutex.unlock();
    if (!res)
    {
      printf("end of stream!\n");
      stopPlayer();
      break;
    }

    if (image.isValid())
    {
      // we have a valid frame - decode and enqueue it
      processImage(mStream.currentFrame(), image);
    }
    else
    {
      fprintf(stderr, "read invalid image\n");
    }

    // if our buffer is full, take rest
    while (bufferCount() >= 5 && !shouldStop())
    {
      fprintf(stderr, "buffer full, sleeping\n");
      msleep(20);
    }
  }

  // enqueue invalid frame to signal that we've finished
  mBufferMutex.lock();
  LadybugPlayerFrame invalidFrame;
  invalidFrame.frameId = -1;
  mBuffer.enqueue(invalidFrame);
  mHasFrame.wakeOne();
  mBufferMutex.unlock();
}
void KNMusicBackendQtAVThread::onActionMediaStateChanged(
        const QtAV::MediaStatus &status)
{
    //Check out the status.
    switch(status)
    {
    case QtAV::InvalidMedia:
        //Because the media is invalid, loaded should be failed.
        emit loadFailed();
        break;
    case QtAV::EndOfMedia:
        //This should means we have played to the end of the file.
        //Stop the player.
        stopPlayer();
        //Emit finished signal.
        emit finished();
        break;
    default:
        break;
    }
}
Beispiel #17
0
///Hide or show the media player
void HistoryTreeItem::showRecordPlayer()
{
   if (!m_pAudioSlider) {
      m_pPlayer      = new PlayerWidget       ( this      );
      QWidget* r1w   = new QWidget            ( this      );
      QWidget* r2w   = new QWidget            ( this      );
      QVBoxLayout* l = new QVBoxLayout        ( m_pPlayer );
      QHBoxLayout* r1= new QHBoxLayout        ( r1w       );
      QHBoxLayout* r2= new QHBoxLayout        ( r2w       );
      m_pAudioSlider = new Phonon::SeekSlider ( this      );
      m_pTimeLeftL   = new QLabel             ( "00:00"   );
      m_pTimePlayedL = new QLabel             ( "00:00"   );
      m_pPause       = new QToolButton        (           );
      m_pStop        = new QToolButton        (           );
      m_pNote        = new QToolButton        (           );

      l->addWidget(r1w);
      l->addWidget(r2w);

      m_pPlayer->setAttribute( Qt::WA_TranslucentBackground, true );
      m_pPlayer->setMinimumSize(0,25);
      m_pPlayer->setStyleSheet("margin-top:5px");

      l-> setContentsMargins(0,0,0,0);
      r1->setContentsMargins(0,0,0,0);
      r2->setContentsMargins(0,0,0,0);

      m_pPause->setIcon ( KIcon( "media-playback-pause" ));
      m_pStop->setIcon  ( KIcon( "media-playback-stop"  ));
      m_pNote->setIcon  ( KIcon( "view-pim-notes"       ));

      m_pPause->setMinimumSize(30,30);
      m_pStop->setMinimumSize (30,30);
      m_pNote->setMinimumSize (30,30);
      QSpacerItem* hSpacer = new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Minimum);

      r1->addWidget( m_pTimePlayedL );
      r1->addWidget( m_pAudioSlider );
      r1->addWidget( m_pTimeLeftL   );
      r2->addWidget( m_pPause       );
      r2->addWidget( m_pStop        );
      r2->addItem  ( hSpacer        );
      r2->addWidget( m_pNote        );

      m_pPlayer->setMinimumSize(width(),height());
      m_pPlayer->setMaximumSize(width(),height());

      l->addItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Expanding));
      m_pPlayer->setVisible(true);

      m_pAudioOutput             = new Phonon::AudioOutput(Phonon::MusicCategory, this);
      m_pMediaObject             = new Phonon::MediaObject(this);
      m_pMetaInformationResolver = new Phonon::MediaObject(this);
      Phonon::createPath(m_pMediaObject, m_pAudioOutput);

      m_pAudioSlider->setMediaObject(m_pMediaObject);

      m_pMediaObject->setTickInterval(1000);

      connect( m_pStop        , SIGNAL(clicked()    ) , this , SLOT( stopPlayer()      ));
      connect( m_pPause       , SIGNAL(clicked()    ) , this , SLOT( playPausePlayer() ));
      connect( m_pNote        , SIGNAL(clicked()    ) , this , SLOT( editNote()        ));
      connect( m_pMediaObject , SIGNAL(tick(qint64) ) , this , SLOT( tick(qint64)      ));

      connect(m_pMediaObject  , SIGNAL(stateChanged(Phonon::State,Phonon::State)),
              this, SLOT(stateChanged(Phonon::State,Phonon::State)));

   }
   kDebug() << "Path:" << m_pItemCall->getRecordingPath();
   m_pPlayer->setVisible(true);
   Phonon::MediaSource source(m_pItemCall->getRecordingPath());
   m_lSources.append(source);
   if (m_lSources.size() > 0)
      m_pMetaInformationResolver->setCurrentSource(m_lSources.first());
   m_pMediaObject->play();

}
Beispiel #18
0
void DM_Music_Stop(void)
{
    stopPlayer();
}