1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-01 01:51:58 +02:00

* Fixed handling Phonon's StoppedState.

This commit is contained in:
Christian Muehlhaeuser
2011-02-24 02:20:05 +01:00
parent 11caacb96c
commit 82b8892b99
3 changed files with 17 additions and 20 deletions

View File

@@ -43,7 +43,7 @@ AudioEngine::AudioEngine()
AudioEngine::~AudioEngine() AudioEngine::~AudioEngine()
{ {
qDebug() << Q_FUNC_INFO << "waiting for event loop to finish..."; qDebug() << Q_FUNC_INFO;
stop(); stop();
@@ -51,16 +51,17 @@ AudioEngine::~AudioEngine()
delete m_mediaObject; delete m_mediaObject;
} }
void void
AudioEngine::playPause() AudioEngine::playPause()
{ {
if( isPlaying() ) if ( isPlaying() )
pause(); pause();
else else
play(); play();
} }
void void
AudioEngine::play() AudioEngine::play()
{ {
@@ -127,25 +128,22 @@ AudioEngine::setVolume( int percentage )
//qDebug() << Q_FUNC_INFO; //qDebug() << Q_FUNC_INFO;
percentage = qBound( 0, percentage, 100 ); percentage = qBound( 0, percentage, 100 );
m_audioOutput->setVolume( (qreal)percentage / 100.0 ); m_audioOutput->setVolume( (qreal)percentage / 100.0 );
emit volumeChanged( percentage ); emit volumeChanged( percentage );
} }
void void
AudioEngine::mute() AudioEngine::mute()
{ {
setVolume( 0 ); setVolume( 0 );
} }
void void
AudioEngine::onTrackAboutToClose() AudioEngine::onTrackAboutToFinish()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
// the only way the iodev we are reading from closes itself, is if
// there was a failure, usually network went away.
// but we might as well play the remaining data we received
// stop();
} }
@@ -170,8 +168,6 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
qDebug() << "Error getting iodevice for item"; qDebug() << "Error getting iodevice for item";
err = true; err = true;
} }
else
connect( io.data(), SIGNAL( aboutToClose() ), SLOT( onTrackAboutToClose() ), Qt::DirectConnection );
} }
if ( !err ) if ( !err )
@@ -181,13 +177,14 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
if ( !m_input.isNull() ) if ( !m_input.isNull() )
{ {
m_expectStop = true;
m_input->close(); m_input->close();
m_input.clear(); m_input.clear();
} }
m_input = io; m_input = io;
m_mediaObject->setCurrentSource( io.data() ) ; m_mediaObject->setCurrentSource( io.data() );
m_mediaObject->play(); m_mediaObject->play();
emit started( m_currentTrack ); emit started( m_currentTrack );
@@ -268,11 +265,14 @@ AudioEngine::onStateChanged( Phonon::State newState, Phonon::State oldState )
qDebug() << Q_FUNC_INFO << oldState << newState; qDebug() << Q_FUNC_INFO << oldState << newState;
if ( oldState == Phonon::PlayingState && newState == Phonon::StoppedState ) if ( oldState == Phonon::PlayingState && newState == Phonon::StoppedState )
{ {
if ( m_expectStop ) if ( !m_expectStop )
return; {
m_expectStop = false;
loadNextTrack(); loadNextTrack();
}
} }
m_expectStop = false;
} }

View File

@@ -56,7 +56,7 @@ public slots:
void setPlaylist( PlaylistInterface* playlist ) { m_playlist = playlist; } void setPlaylist( PlaylistInterface* playlist ) { m_playlist = playlist; }
void setQueue( PlaylistInterface* queue ) { m_queue = queue; } void setQueue( PlaylistInterface* queue ) { m_queue = queue; }
void onTrackAboutToClose(); void onTrackAboutToFinish();
signals: signals:
void loading( const Tomahawk::result_ptr& track ); void loading( const Tomahawk::result_ptr& track );

View File

@@ -158,7 +158,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
new TomahawkSettings( this ); new TomahawkSettings( this );
m_audioEngine = new AudioEngine; m_audioEngine = new AudioEngine;
new ScanManager( this ); new ScanManager( this );
new Pipeline( this ); new Pipeline( this );
m_servent = new Servent( this ); m_servent = new Servent( this );
@@ -167,8 +166,6 @@ TomahawkApp::TomahawkApp( int& argc, char *argv[] )
qDebug() << "Init Database."; qDebug() << "Init Database.";
setupDatabase(); setupDatabase();
new SourceList( this );
qDebug() << "Init Echonest Factory."; qDebug() << "Init Echonest Factory.";
GeneratorFactory::registerFactory( "echonest", new EchonestFactory ); GeneratorFactory::registerFactory( "echonest", new EchonestFactory );