From 190a0111ccd874923bf88dac938531a18f52e698 Mon Sep 17 00:00:00 2001 From: bipolar Date: Fri, 01 Feb 2002 18:41:28 +0000 Subject: Mediaplayer hang fix --- diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp index b2b876f..9d04f7e 100644 --- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp +++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp @@ -493,7 +493,7 @@ bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long sampl static bool needInput = TRUE; if ( samples == 0 ) - return TRUE; + return FALSE; do { if ( needInput ) @@ -501,13 +501,13 @@ bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long sampl // if ( d->input.eof ) // needInput = FALSE; // else - return TRUE; + return FALSE; } needInput = FALSE; if ( decode( output, samples, samplesMade ) ) - return FALSE; + return TRUE; else needInput = TRUE; } @@ -521,7 +521,7 @@ bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long sampl return FALSE; } else */ - return TRUE; + return FALSE; } diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 93a6e3f..6dfd057 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -228,7 +228,7 @@ void LoopControl::startAudio() { qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); long samplesRead = 0; - mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); + bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; long sampleWaitTime = currentSample - sampleWeShouldBeAt; @@ -243,7 +243,7 @@ void LoopControl::startAudio() { audioDevice->write( audioBuffer, samplesRead * 2 * channels ); audioSampleCounter = currentSample + samplesRead - 1; - moreAudio = audioSampleCounter <= total_audio_samples; + moreAudio = readOk && (audioSampleCounter <= total_audio_samples); } else { diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp index 60a0024..a6bd974 100644 --- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp +++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp @@ -323,7 +323,7 @@ bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& sampl bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { debugMsg( "WavPlugin::audioReadSamples" ); - return !d->add( output, samples, samplesMade, channels != 1 ); + return d->add( output, samples, samplesMade, channels != 1 ); } double WavPlugin::getTime() { -- cgit v0.9.0.2