mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-07-09 16:46:37 +02:00
* Ok, let's try that publicly. AudioState queue to work around the Phonon state mess.
This commit is contained in:
@ -133,9 +133,7 @@ AudioEngine::play()
|
|||||||
|
|
||||||
if ( isPaused() )
|
if ( isPaused() )
|
||||||
{
|
{
|
||||||
setVolume( m_volume );
|
queueState( Playing );
|
||||||
m_mediaObject->play();
|
|
||||||
setVolume( m_volume );
|
|
||||||
emit resumed();
|
emit resumed();
|
||||||
|
|
||||||
sendNowPlayingNotification( Tomahawk::InfoSystem::InfoNowResumed );
|
sendNowPlayingNotification( Tomahawk::InfoSystem::InfoNowResumed );
|
||||||
@ -151,7 +149,8 @@ AudioEngine::pause()
|
|||||||
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
tDebug( LOGEXTRA ) << Q_FUNC_INFO;
|
||||||
|
|
||||||
m_volume = volume();
|
m_volume = volume();
|
||||||
m_mediaObject->pause();
|
|
||||||
|
queueState( Paused );
|
||||||
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 ) );
|
||||||
@ -185,7 +184,6 @@ AudioEngine::stop( AudioErrorCode errorCode )
|
|||||||
sendWaitingNotification();
|
sendWaitingNotification();
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoPushData pushData( s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowStopped, QVariant(), Tomahawk::InfoSystem::PushNoFlag );
|
Tomahawk::InfoSystem::InfoPushData pushData( s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNowStopped, QVariant(), Tomahawk::InfoSystem::PushNoFlag );
|
||||||
|
|
||||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo( pushData );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -485,8 +483,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
|||||||
m_input.clear();
|
m_input.clear();
|
||||||
}
|
}
|
||||||
m_input = io;
|
m_input = io;
|
||||||
m_mediaObject->play();
|
queueState( Playing );
|
||||||
|
|
||||||
emit started( m_currentTrack );
|
emit started( m_currentTrack );
|
||||||
|
|
||||||
if ( TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::FullyPrivate )
|
if ( TomahawkSettings::instance()->privateListeningMode() != TomahawkSettings::FullyPrivate )
|
||||||
@ -734,6 +731,16 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( newState == Phonon::PausedState || newState == Phonon::PlayingState )
|
||||||
|
{
|
||||||
|
tDebug() << "Phonon state now:" << newState;
|
||||||
|
if ( m_stateQueue.count() )
|
||||||
|
{
|
||||||
|
AudioState qState = m_stateQueue.dequeue();
|
||||||
|
checkStateQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -835,6 +842,47 @@ AudioEngine::isLocalResult( const QString& url ) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioEngine::checkStateQueue()
|
||||||
|
{
|
||||||
|
if ( m_stateQueue.count() )
|
||||||
|
{
|
||||||
|
AudioState state = m_stateQueue.head();
|
||||||
|
tDebug() << "Applying state command:" << state;
|
||||||
|
switch ( state )
|
||||||
|
{
|
||||||
|
case Playing:
|
||||||
|
{
|
||||||
|
setVolume( m_volume );
|
||||||
|
m_mediaObject->play();
|
||||||
|
setVolume( m_volume );
|
||||||
|
}
|
||||||
|
|
||||||
|
case Paused:
|
||||||
|
{
|
||||||
|
m_mediaObject->pause();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
tDebug() << "Queue is empty";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
AudioEngine::queueState( AudioState state )
|
||||||
|
{
|
||||||
|
tDebug() << "Enqueuing state command:" << state << m_stateQueue.count();
|
||||||
|
|
||||||
|
m_stateQueue.enqueue( state );
|
||||||
|
|
||||||
|
if ( m_stateQueue.count() == 1 )
|
||||||
|
{
|
||||||
|
checkStateQueue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioEngine::setState( AudioState state )
|
AudioEngine::setState( AudioState state )
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
|
#include <QtCore/QQueue>
|
||||||
|
|
||||||
#include <phonon/MediaObject>
|
#include <phonon/MediaObject>
|
||||||
#include <phonon/AudioOutput>
|
#include <phonon/AudioOutput>
|
||||||
@ -29,13 +30,12 @@
|
|||||||
|
|
||||||
#include "libtomahawk/infosystem/InfoSystem.h"
|
#include "libtomahawk/infosystem/InfoSystem.h"
|
||||||
|
|
||||||
#include "Result.h"
|
|
||||||
#include "Typedefs.h"
|
#include "Typedefs.h"
|
||||||
|
#include "Result.h"
|
||||||
#include "PlaylistInterface.h"
|
#include "PlaylistInterface.h"
|
||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
|
|
||||||
class DLLEXPORT AudioEngine : public QObject
|
class DLLEXPORT AudioEngine : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -139,6 +139,9 @@ private slots:
|
|||||||
void sendWaitingNotification() const;
|
void sendWaitingNotification() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void checkStateQueue();
|
||||||
|
void queueState( AudioState state );
|
||||||
|
|
||||||
void setState( AudioState state );
|
void setState( AudioState state );
|
||||||
|
|
||||||
bool isHttpResult( const QString& ) const;
|
bool isHttpResult( const QString& ) const;
|
||||||
@ -162,9 +165,11 @@ private:
|
|||||||
bool m_waitingOnNewTrack;
|
bool m_waitingOnNewTrack;
|
||||||
|
|
||||||
mutable QStringList m_supportedMimeTypes;
|
mutable QStringList m_supportedMimeTypes;
|
||||||
AudioState m_state;
|
|
||||||
unsigned int m_volume;
|
unsigned int m_volume;
|
||||||
|
|
||||||
|
AudioState m_state;
|
||||||
|
QQueue< AudioState > m_stateQueue;
|
||||||
|
|
||||||
static AudioEngine* s_instance;
|
static AudioEngine* s_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user