mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-03-31 06:02:27 +02:00
Rip out retry timer and move to a push solution. Untested, will test
later.
This commit is contained in:
parent
555adeaac7
commit
bf015d241a
@ -70,6 +70,8 @@ signals:
|
||||
void tracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||
|
@ -71,6 +71,8 @@ signals:
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void onTracksAdded( const QList<Tomahawk::query_ptr>& tracks );
|
||||
|
||||
|
@ -52,6 +52,7 @@ AudioEngine::AudioEngine()
|
||||
, m_queue( 0 )
|
||||
, m_timeElapsed( 0 )
|
||||
, m_expectStop( false )
|
||||
, m_waitingOnNewTrack( false )
|
||||
{
|
||||
s_instance = this;
|
||||
qDebug() << "Init AudioEngine";
|
||||
@ -75,17 +76,12 @@ AudioEngine::AudioEngine()
|
||||
// Since it's indendent, we'll set it to 75% since that's nicer
|
||||
setVolume( 75 );
|
||||
#endif
|
||||
|
||||
m_retryTimer.setInterval( 10000 );
|
||||
m_retryTimer.setSingleShot( false );
|
||||
connect( &m_retryTimer, SIGNAL( timeout() ), SLOT( loadNextTrack() ) );
|
||||
}
|
||||
|
||||
|
||||
AudioEngine::~AudioEngine()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
m_retryTimer.stop();
|
||||
m_mediaObject->stop();
|
||||
// stop();
|
||||
|
||||
@ -144,8 +140,7 @@ AudioEngine::stop( bool sendNotification )
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_mediaObject->stop();
|
||||
m_retryTimer.stop();
|
||||
|
||||
|
||||
if ( m_playlist )
|
||||
m_playlist->reset();
|
||||
|
||||
@ -255,8 +250,6 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << thread() << result;
|
||||
|
||||
m_retryTimer.stop();
|
||||
|
||||
bool err = false;
|
||||
|
||||
{
|
||||
@ -344,6 +337,7 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
|
||||
return false;
|
||||
}
|
||||
|
||||
m_waitingOnNewTrack = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -352,8 +346,6 @@ AudioEngine::loadPreviousTrack()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
m_retryTimer.stop();
|
||||
|
||||
if ( !m_playlist )
|
||||
{
|
||||
stop();
|
||||
@ -373,9 +365,6 @@ AudioEngine::loadNextTrack()
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO;
|
||||
|
||||
bool wasRetrying = m_retryTimer.isActive();
|
||||
m_retryTimer.stop();
|
||||
|
||||
Tomahawk::result_ptr result;
|
||||
|
||||
if ( m_queue && m_queue->trackCount() )
|
||||
@ -395,16 +384,12 @@ AudioEngine::loadNextTrack()
|
||||
stop( false );
|
||||
if ( m_playlist && m_playlist->retryMode() == Tomahawk::PlaylistInterface::Retry )
|
||||
{
|
||||
if ( !wasRetrying )
|
||||
{
|
||||
Tomahawk::InfoSystem::InfoCriteriaHash retryInfo;
|
||||
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will keep trying..." );
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( retryInfo ) );
|
||||
}
|
||||
m_retryTimer.setInterval( m_playlist->retryInterval() );
|
||||
m_retryTimer.start();
|
||||
m_waitingOnNewTrack = true;
|
||||
Tomahawk::InfoSystem::InfoCriteriaHash retryInfo;
|
||||
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track..." );
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( retryInfo ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -417,7 +402,7 @@ AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::re
|
||||
|
||||
if ( m_playlist )
|
||||
m_playlist->reset();
|
||||
|
||||
|
||||
setPlaylist( playlist );
|
||||
m_currentTrackPlaylist = playlist;
|
||||
|
||||
@ -425,17 +410,27 @@ AudioEngine::playItem( Tomahawk::PlaylistInterface* playlist, const Tomahawk::re
|
||||
loadTrack( result );
|
||||
else if ( m_playlist->retryMode() == PlaylistInterface::Retry )
|
||||
{
|
||||
m_waitingOnNewTrack = true;
|
||||
Tomahawk::InfoSystem::InfoCriteriaHash retryInfo;
|
||||
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will keep trying..." );
|
||||
retryInfo["message"] = QString( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track..." );
|
||||
Tomahawk::InfoSystem::InfoSystem::instance()->pushInfo(
|
||||
s_aeInfoIdentifier, Tomahawk::InfoSystem::InfoNotifyUser,
|
||||
QVariant::fromValue< Tomahawk::InfoSystem::InfoCriteriaHash >( retryInfo ) );
|
||||
m_retryTimer.setInterval( playlist->retryInterval() );
|
||||
m_retryTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::playlistNextTrackReady()
|
||||
{
|
||||
if ( !m_waitingOnNewTrack )
|
||||
return;
|
||||
|
||||
m_waitingOnNewTrack = false;
|
||||
next();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioEngine::onAboutToFinish()
|
||||
{
|
||||
@ -498,6 +493,10 @@ AudioEngine::setPlaylist( PlaylistInterface* playlist )
|
||||
if ( m_playlist )
|
||||
m_playlist->reset();
|
||||
m_playlist = playlist;
|
||||
|
||||
if ( m_playlist->retryMode() == PlaylistInterface::Retry )
|
||||
connect( m_playlist->object(), SIGNAL( nextTrackReady() ), SLOT( playlistNextTrackReady() ) );
|
||||
|
||||
emit playlistChanged( playlist );
|
||||
}
|
||||
|
||||
|
@ -83,6 +83,8 @@ public slots:
|
||||
|
||||
void onTrackAboutToFinish();
|
||||
|
||||
void playlistNextTrackReady();
|
||||
|
||||
signals:
|
||||
void loading( const Tomahawk::result_ptr& track );
|
||||
void started( const Tomahawk::result_ptr& track );
|
||||
@ -131,7 +133,7 @@ private:
|
||||
unsigned int m_timeElapsed;
|
||||
bool m_expectStop;
|
||||
|
||||
QTimer m_retryTimer;
|
||||
bool m_waitingOnNewTrack;
|
||||
|
||||
static AudioEngine* s_instance;
|
||||
};
|
||||
|
@ -208,6 +208,8 @@ signals:
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
// want to update the playlist from the model?
|
||||
// generate a newrev using uuid() and call this:
|
||||
|
@ -65,6 +65,8 @@ signals:
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
@ -74,6 +74,8 @@ signals:
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
@ -70,6 +70,8 @@ signals:
|
||||
|
||||
void filterChanged( const QString& filter );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
public slots:
|
||||
virtual void setRepeatMode( RepeatMode mode ) { m_repeatMode = mode; emit repeatModeChanged( mode ); }
|
||||
virtual void setShuffled( bool enabled ) { m_shuffled = enabled; emit shuffleModeChanged( enabled ); }
|
||||
|
@ -32,6 +32,7 @@ namespace Tomahawk
|
||||
|
||||
class DLLEXPORT PlaylistInterface
|
||||
{
|
||||
|
||||
public:
|
||||
enum RepeatMode { NoRepeat, RepeatOne, RepeatAll };
|
||||
enum ViewMode { Unknown, Tree, Flat, Album };
|
||||
@ -78,6 +79,7 @@ signals:
|
||||
virtual void shuffleModeChanged( bool enabled ) = 0;
|
||||
virtual void trackCountChanged( unsigned int tracks ) = 0;
|
||||
virtual void sourceTrackCountChanged( unsigned int tracks ) = 0;
|
||||
virtual void nextTrackReady() = 0;
|
||||
|
||||
private:
|
||||
QObject* m_object;
|
||||
|
@ -114,7 +114,8 @@ SourcePlaylistInterface::resolveResultsAdded( const QList<Tomahawk::result_ptr>&
|
||||
}
|
||||
|
||||
void
|
||||
SourcePlaylistInterface::resolvingFinished( bool hasResults ) const
|
||||
SourcePlaylistInterface::resolvingFinished( bool hasResults )
|
||||
{
|
||||
qDebug() << Q_FUNC_INFO << " and has results? : " << (hasResults ? "true" : "false");
|
||||
emit nextTrackReady();
|
||||
}
|
@ -70,11 +70,12 @@ signals:
|
||||
void shuffleModeChanged( bool enabled );
|
||||
void trackCountChanged( unsigned int tracks );
|
||||
void sourceTrackCountChanged( unsigned int tracks );
|
||||
|
||||
void nextTrackReady();
|
||||
|
||||
private slots:
|
||||
void onSourcePlaybackStarted( const Tomahawk::query_ptr& query );
|
||||
void resolveResultsAdded( const QList<Tomahawk::result_ptr>& results ) const;
|
||||
void resolvingFinished( bool hasResults ) const;
|
||||
void resolvingFinished( bool hasResults );
|
||||
|
||||
private:
|
||||
Tomahawk::source_ptr m_source;
|
||||
|
Loading…
x
Reference in New Issue
Block a user