mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-04 21:27:58 +02:00
* Get rid of fugly state-queue handling in AudioEngine.
This commit is contained in:
@@ -146,16 +146,6 @@ AudioEnginePrivate::onStateChanged( Phonon::State newState, Phonon::State oldSta
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( newState == Phonon::PausedState || newState == Phonon::PlayingState || newState == Phonon::ErrorState )
|
|
||||||
{
|
|
||||||
tDebug( LOGVERBOSE ) << "Phonon state now:" << newState;
|
|
||||||
if ( stateQueue.count() )
|
|
||||||
{
|
|
||||||
/*/ AudioState qState = */ stateQueue.dequeue();
|
|
||||||
q_ptr->checkStateQueue();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -233,13 +223,8 @@ AudioEngine::AudioEngine()
|
|||||||
connect( d->mediaObject, SIGNAL( stateChanged( Phonon::State, Phonon::State ) ), d_func(), SLOT( onStateChanged( Phonon::State, Phonon::State ) ) );
|
connect( d->mediaObject, SIGNAL( stateChanged( Phonon::State, Phonon::State ) ), d_func(), SLOT( onStateChanged( Phonon::State, Phonon::State ) ) );
|
||||||
connect( d->mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) );
|
connect( d->mediaObject, SIGNAL( tick( qint64 ) ), SLOT( timerTriggered( qint64 ) ) );
|
||||||
connect( d->mediaObject, SIGNAL( aboutToFinish() ), SLOT( onAboutToFinish() ) );
|
connect( d->mediaObject, SIGNAL( aboutToFinish() ), SLOT( onAboutToFinish() ) );
|
||||||
|
|
||||||
connect( d->audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
|
connect( d->audioOutput, SIGNAL( volumeChanged( qreal ) ), SLOT( onVolumeChanged( qreal ) ) );
|
||||||
|
|
||||||
d->stateQueueTimer.setInterval( 5000 );
|
|
||||||
d->stateQueueTimer.setSingleShot( true );
|
|
||||||
connect( &d->stateQueueTimer, SIGNAL( timeout() ), SLOT( queueStateSafety() ) );
|
|
||||||
|
|
||||||
onVolumeChanged( d->audioOutput->volume() );
|
onVolumeChanged( d->audioOutput->volume() );
|
||||||
|
|
||||||
setVolume( TomahawkSettings::instance()->volume() );
|
setVolume( TomahawkSettings::instance()->volume() );
|
||||||
@@ -294,7 +279,7 @@ AudioEngine::play()
|
|||||||
|
|
||||||
if ( isPaused() )
|
if ( isPaused() )
|
||||||
{
|
{
|
||||||
queueState( Playing );
|
d->mediaObject->play();
|
||||||
emit resumed();
|
emit resumed();
|
||||||
|
|
||||||
sendNowPlayingNotification( Tomahawk::InfoSystem::InfoNowResumed );
|
sendNowPlayingNotification( Tomahawk::InfoSystem::InfoNowResumed );
|
||||||
@@ -314,9 +299,11 @@ AudioEngine::play()
|
|||||||
void
|
void
|
||||||
AudioEngine::pause()
|
AudioEngine::pause()
|
||||||
{
|
{
|
||||||
|
Q_D( AudioEngine );
|
||||||
|
|
||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||||
|
|
||||||
queueState( Paused );
|
d->mediaObject->pause();
|
||||||
emit paused();
|
emit paused();
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( Tomahawk::InfoSystem::InfoPushData( s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPaused, QVariant(), Tomahawk::InfoSystem::PushNoFlag ) );
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( Tomahawk::InfoSystem::InfoPushData( s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowPaused, QVariant(), Tomahawk::InfoSystem::PushNoFlag ) );
|
||||||
@@ -737,7 +724,7 @@ AudioEngine::performLoadTrack( const Tomahawk::result_ptr& result, QSharedPointe
|
|||||||
d->input.clear();
|
d->input.clear();
|
||||||
}
|
}
|
||||||
d->input = ioToKeep;
|
d->input = ioToKeep;
|
||||||
queueState( Playing );
|
d->mediaObject->play();
|
||||||
|
|
||||||
if ( TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::FullyPrivate )
|
if ( TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::FullyPrivate )
|
||||||
{
|
{
|
||||||
@@ -1146,68 +1133,6 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AudioEngine::checkStateQueue()
|
|
||||||
{
|
|
||||||
Q_D( AudioEngine );
|
|
||||||
|
|
||||||
if ( d->stateQueue.count() )
|
|
||||||
{
|
|
||||||
AudioState state = (AudioState) d->stateQueue.head();
|
|
||||||
tDebug( LOGVERBOSE ) << "Applying state command:" << state;
|
|
||||||
switch ( state )
|
|
||||||
{
|
|
||||||
case Playing:
|
|
||||||
{
|
|
||||||
d->mediaObject->play();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case Paused:
|
|
||||||
{
|
|
||||||
d->mediaObject->pause();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Queue is empty";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AudioEngine::queueStateSafety()
|
|
||||||
{
|
|
||||||
Q_D( AudioEngine );
|
|
||||||
|
|
||||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO;
|
|
||||||
d->stateQueue.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
AudioEngine::queueState( AudioState state )
|
|
||||||
{
|
|
||||||
Q_D( AudioEngine );
|
|
||||||
|
|
||||||
if ( d->stateQueueTimer.isActive() )
|
|
||||||
d->stateQueueTimer.stop();
|
|
||||||
|
|
||||||
tDebug( LOGVERBOSE ) << "Enqueuing state command:" << state << d->stateQueue.count();
|
|
||||||
d->stateQueue.enqueue( state );
|
|
||||||
|
|
||||||
if ( d->stateQueue.count() == 1 )
|
|
||||||
{
|
|
||||||
checkStateQueue();
|
|
||||||
}
|
|
||||||
|
|
||||||
d->stateQueueTimer.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::setState( AudioState state )
|
AudioEngine::setState( AudioState state )
|
||||||
{
|
{
|
||||||
|
@@ -147,11 +147,7 @@ private slots:
|
|||||||
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
void sendNowPlayingNotification( const Tomahawk::InfoSystem::InfoType type );
|
||||||
void sendWaitingNotification() const;
|
void sendWaitingNotification() const;
|
||||||
|
|
||||||
void queueStateSafety();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkStateQueue();
|
|
||||||
void queueState( AudioState state );
|
|
||||||
void setState( AudioState state );
|
void setState( AudioState state );
|
||||||
void setCurrentTrackPlaylist( const Tomahawk::playlistinterface_ptr& playlist );
|
void setCurrentTrackPlaylist( const Tomahawk::playlistinterface_ptr& playlist );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user