author | llornkcor <llornkcor> | 2002-05-05 18:09:38 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-05-05 18:09:38 (UTC) |
commit | 4cd02e41953be5b271c877197cf9c12ad4785bef (patch) (side-by-side diff) | |
tree | f530836dc741188e869c64d29c73df0142b01f11 | |
parent | a68eb5375bd8dc5f9cb3ea9b1785d923a4412edc (diff) | |
download | opie-4cd02e41953be5b271c877197cf9c12ad4785bef.zip opie-4cd02e41953be5b271c877197cf9c12ad4785bef.tar.gz opie-4cd02e41953be5b271c877197cf9c12ad4785bef.tar.bz2 |
bug fix
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index faa8e56..310d512 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp @@ -334,88 +334,88 @@ void LoopControl::stop( bool willPlayAgainShortly ) { killTimers(); audioMutex->lock(); mediaPlayerState->curDecoder()->close(); if ( audioDevice ) { delete audioDevice; delete audioBuffer; audioDevice = 0; audioBuffer = 0; } audioMutex->unlock(); } } bool LoopControl::init( const QString& filename ) { stop(); audioMutex->lock(); fileName = filename; stream = 0; // only play stream 0 for now current_frame = total_video_frames = total_audio_samples = 0; qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { - if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { - total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); - mediaPlayerState->libMpeg3Decoder()->close(); - } + if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { + total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); + mediaPlayerState->libMpeg3Decoder()->close(); + } } if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { audioMutex->unlock(); return FALSE; } hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; if ( hasAudioChannel ) { int astream = 0; channels = mediaPlayerState->curDecoder()->audioChannels( astream ); qDebug( "LC- channels = %d", channels ); if ( !total_audio_samples ) total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); -// total_audio_samples += 1000; + total_audio_samples += 1000; mediaPlayerState->setLength( total_audio_samples ); freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); qDebug( "LC- frequency = %d", freq ); audioSampleCounter = 0; int bits_per_sample; if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); qDebug("using stupid hack"); } else { bits_per_sample=0; } audioDevice = new AudioDevice( freq, channels, bits_per_sample); audioBuffer = new char[ audioDevice->bufferSize() ]; channels = audioDevice->channels(); //### must check which frequency is actually used. static const int size = 1; short int buf[size]; long samplesRead = 0; mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); } if ( hasVideoChannel ) { total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); mediaPlayerState->setLength( total_video_frames ); framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); |