From 69f41c41e8e1b329a249a98406b405c95c2684c1 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 19 May 2012 07:23:33 +0200 Subject: [PATCH] * Let AudioEngine wait for a query to finish resolving and start playback asap. --- src/libtomahawk/PlaylistInterface.h | 4 +++- src/libtomahawk/audio/AudioEngine.cpp | 22 +++++++++++----------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/libtomahawk/PlaylistInterface.h b/src/libtomahawk/PlaylistInterface.h index e6b405575..36671ae26 100644 --- a/src/libtomahawk/PlaylistInterface.h +++ b/src/libtomahawk/PlaylistInterface.h @@ -105,6 +105,8 @@ private: QString m_filter; }; -}; +} + +Q_DECLARE_METATYPE( Tomahawk::playlistinterface_ptr ) #endif // PLAYLISTINTERFACE_H diff --git a/src/libtomahawk/audio/AudioEngine.cpp b/src/libtomahawk/audio/AudioEngine.cpp index dbde95469..eab4d246e 100644 --- a/src/libtomahawk/audio/AudioEngine.cpp +++ b/src/libtomahawk/audio/AudioEngine.cpp @@ -579,8 +579,16 @@ AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk: void AudioEngine::playItem( Tomahawk::playlistinterface_ptr playlist, const Tomahawk::query_ptr& query ) { - if ( !query.isNull() && query->numResults() ) - playItem( playlist, query->results().first() ); + if ( query->resolvingFinished() ) + { + if ( query->numResults() ) + playItem( playlist, query->results().first() ); + } + else + { + _detail::Closure* closure = NewClosure( query.data(), SIGNAL( resolvingFinished( bool ) ), + const_cast(this), SLOT( playItem( Tomahawk::playlistinterface_ptr, Tomahawk::query_ptr ) ), playlist, query ); + } } @@ -605,15 +613,7 @@ AudioEngine::playItem( const Tomahawk::album_ptr& album ) playlistinterface_ptr pli = album->playlistInterface( Mixed ); if ( pli->trackCount() ) { - if ( pli->tracks().first()->resolvingFinished() ) - { - playItem( pli, pli->tracks().first() ); - } - else - { - _detail::Closure* closure = NewClosure( pli->tracks().first().data(), SIGNAL( resolvingFinished( bool ) ), - const_cast(this), SLOT( playItem( Tomahawk::album_ptr ) ), album ); - } + playItem( pli, pli->tracks().first() ); } else {