1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-20 04:41:36 +02:00

Call AudioEngine in the correct thread

This commit is contained in:
Uwe L. Korn
2014-07-01 17:02:48 +01:00
parent 279177be62
commit 52701463cc

View File

@@ -264,6 +264,13 @@ AudioEngine::supportedMimeTypes() const
void void
AudioEngine::playPause() AudioEngine::playPause()
{ {
if ( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this, "playPause", Qt::QueuedConnection );
return;
}
if ( isPlaying() ) if ( isPlaying() )
pause(); pause();
else else
@@ -274,6 +281,12 @@ AudioEngine::playPause()
void void
AudioEngine::play() AudioEngine::play()
{ {
if ( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this, "play", Qt::QueuedConnection );
return;
}
Q_D( AudioEngine ); Q_D( AudioEngine );
tDebug( LOGEXTRA ) << Q_FUNC_INFO; tDebug( LOGEXTRA ) << Q_FUNC_INFO;
@@ -300,6 +313,12 @@ AudioEngine::play()
void void
AudioEngine::pause() AudioEngine::pause()
{ {
if ( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this, "pause", Qt::QueuedConnection );
return;
}
Q_D( AudioEngine ); Q_D( AudioEngine );
tDebug( LOGEXTRA ) << Q_FUNC_INFO; tDebug( LOGEXTRA ) << Q_FUNC_INFO;
@@ -314,6 +333,12 @@ AudioEngine::pause()
void void
AudioEngine::stop( AudioErrorCode errorCode ) AudioEngine::stop( AudioErrorCode errorCode )
{ {
if ( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this, "stop", Qt::QueuedConnection );
return;
}
Q_D( AudioEngine ); Q_D( AudioEngine );
tDebug() << Q_FUNC_INFO << errorCode << isStopped(); tDebug() << Q_FUNC_INFO << errorCode << isStopped();
@@ -375,6 +400,12 @@ void AudioEngine::audioDataArrived( QMap< AudioEngine::AudioChannel, QVector< qi
void void
AudioEngine::previous() AudioEngine::previous()
{ {
if ( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this, "previous", Qt::QueuedConnection );
return;
}
tDebug( LOGEXTRA ) << Q_FUNC_INFO; tDebug( LOGEXTRA ) << Q_FUNC_INFO;
if ( canGoPrevious() ) if ( canGoPrevious() )
@@ -385,6 +416,12 @@ AudioEngine::previous()
void void
AudioEngine::next() AudioEngine::next()
{ {
if ( QThread::currentThread() != thread() )
{
QMetaObject::invokeMethod( this, "next", Qt::QueuedConnection );
return;
}
tDebug( LOGEXTRA ) << Q_FUNC_INFO; tDebug( LOGEXTRA ) << Q_FUNC_INFO;
if ( canGoNext() ) if ( canGoNext() )