-rw-r--r-- | core/multimedia/opieplayer/libmad/libmadplugin.cpp | 8 | ||||
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 4 | ||||
-rw-r--r-- | core/multimedia/opieplayer/wavplugin/wavplugin.cpp | 2 |
3 files changed, 7 insertions, 7 deletions
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 @@ -472,77 +472,77 @@ bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { samplesMade = samples; memmove( buffer[0], &(buffer[0][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); if ( d->synth.pcm.channels == 2 ) memmove( buffer[1], &(buffer[1][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); buffered -= samples; return TRUE; } /* bool LibMadPlugin::audioReadMonoSamples( short *, long, long&, int ) { debugMsg( "LibMadPlugin::audioReadMonoSamples" ); return FALSE; } bool LibMadPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { */ bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long samples, long& samplesMade, int ) { debugMsg( "LibMadPlugin::audioReadStereoSamples" ); static bool needInput = TRUE; if ( samples == 0 ) - return TRUE; + return FALSE; do { if ( needInput ) if ( !read() ) { // 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; } while ( ( samplesMade < samples ) && ( !d->input.eof ) ); /* static bool firstTimeThru = TRUE; if ( firstTimeThru ) { firstTimeThru = FALSE; decode( output, samples, samplesMade ); return FALSE; } else */ - return TRUE; + return FALSE; } double LibMadPlugin::getTime() { debugMsg( "LibMadPlugin::getTime" ); return 0.0; } void LibMadPlugin::printID3Tags() { debugMsg( "LibMadPlugin::printID3Tags" ); char id3v1[128 + 1]; if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { qDebug( "error seeking to id3 tags" ); return; } if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { qDebug( "error reading in id3 tags" ); return; } 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 @@ -207,64 +207,64 @@ void LoopControl::startVideo() { moreVideo = FALSE; killTimer( videoId ); } } } void LoopControl::startAudio() { audioMutex->lock(); if ( moreAudio ) { if ( !isMuted && mediaPlayerState->curDecoder() ) { currentSample = audioSampleCounter + 1; if ( currentSample != audioSampleCounter + 1 ) 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; if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); } else if ( sampleWaitTime <= -5000 ) { qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); currentSample = sampleWeShouldBeAt; } audioDevice->write( audioBuffer, samplesRead * 2 * channels ); audioSampleCounter = currentSample + samplesRead - 1; - moreAudio = audioSampleCounter <= total_audio_samples; + moreAudio = readOk && (audioSampleCounter <= total_audio_samples); } else { moreAudio = FALSE; } } audioMutex->unlock(); } void LoopControl::killTimers() { audioMutex->lock(); if ( hasVideoChannel ) killTimer( videoId ); killTimer( sliderId ); threadOkToGo = FALSE; audioMutex->unlock(); } 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 @@ -302,33 +302,33 @@ bool WavPlugin::audioReadSamples( short *, int, long, int ) { return FALSE; } bool WavPlugin::audioReReadSamples( short *, int, long, int ) { debugMsg( "WavPlugin::audioReReadSamples" ); return FALSE; } bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { debugMsg( "WavPlugin::audioReadMonoSamples" ); return !d->add( output, samples, samplesMade, FALSE ); } bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { debugMsg( "WavPlugin::audioReadStereoSamples" ); return !d->add( output, samples, samplesMade, TRUE ); } */ 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() { debugMsg( "WavPlugin::getTime" ); return 0.0; } |