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