1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-20 12:52:30 +02:00

* Fixed HTTP streaming.

This commit is contained in:
Christian Muehlhaeuser
2011-03-18 02:52:00 +01:00
parent ae6ec8eba8
commit 18bf3d655c
2 changed files with 23 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ AudioEngine::~AudioEngine()
delete m_audio; delete m_audio;
} }
void void
AudioEngine::playPause() AudioEngine::playPause()
{ {
@@ -72,6 +73,7 @@ AudioEngine::playPause()
} }
void void
AudioEngine::play() AudioEngine::play()
{ {
@@ -150,12 +152,14 @@ AudioEngine::setVolume( int percentage )
emit volumeChanged( percentage ); emit volumeChanged( percentage );
} }
void void
AudioEngine::mute() AudioEngine::mute()
{ {
setVolume( 0 ); setVolume( 0 );
} }
void void
AudioEngine::onTrackAboutToClose() AudioEngine::onTrackAboutToClose()
{ {
@@ -184,6 +188,13 @@ AudioEngine::loadTrack( const Tomahawk::result_ptr& result )
{ {
setCurrentTrack( result ); setCurrentTrack( result );
io = Servent::instance()->getIODeviceForUrl( m_currentTrack ); io = Servent::instance()->getIODeviceForUrl( m_currentTrack );
if ( m_currentTrack->url().startsWith( "http://" ) )
{
m_readReady = false;
connect( io.data(), SIGNAL( downloadProgress( qint64, qint64 ) ), SLOT( onDownloadProgress( qint64, qint64 ) ) );
}
else
m_readReady = true;
if ( !io || io.isNull() ) if ( !io || io.isNull() )
{ {
@@ -396,6 +407,14 @@ AudioEngine::setCurrentTrack( const Tomahawk::result_ptr& result )
} }
void
AudioEngine::onDownloadProgress( qint64 recv, qint64 total )
{
if ( ( recv > 1024 * 32 ) || recv > total )
m_readReady = true;
}
void void
AudioEngine::run() AudioEngine::run()
{ {
@@ -461,6 +480,7 @@ AudioEngine::loop()
// are we cleanly at the end of a track, and ready for the next one? // are we cleanly at the end of a track, and ready for the next one?
if ( !m_input.isNull() && if ( !m_input.isNull() &&
m_input->atEnd() && m_input->atEnd() &&
m_readReady &&
!m_input->bytesAvailable() && !m_input->bytesAvailable() &&
!m_audio->haveData() && !m_audio->haveData() &&
!m_audio->isPaused() ) !m_audio->isPaused() )

View File

@@ -83,6 +83,8 @@ private slots:
void loadPreviousTrack(); void loadPreviousTrack();
void loadNextTrack(); void loadNextTrack();
void onDownloadProgress( qint64 recv, qint64 total );
void setStreamData( long sampleRate, int channels ); void setStreamData( long sampleRate, int channels );
void timerTriggered( unsigned int seconds ); void timerTriggered( unsigned int seconds );
@@ -111,6 +113,7 @@ private:
PlaylistInterface* m_queue; PlaylistInterface* m_queue;
QMutex m_mutex; QMutex m_mutex;
bool m_readReady;
unsigned int m_timeElapsed; unsigned int m_timeElapsed;
int m_i; int m_i;