summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 6dfd057..859a67a 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -17,7 +17,10 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// L.J.Potter added changes Fri 02-15-2002
21
20#include <qpe/qpeapplication.h> 22#include <qpe/qpeapplication.h>
23
21#ifdef Q_WS_QWS 24#ifdef Q_WS_QWS
22#include <qpe/qcopenvelope_qws.h> 25#include <qpe/qcopenvelope_qws.h>
23#endif 26#endif
@@ -232,13 +235,14 @@ void LoopControl::startAudio() {
232 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 235 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
233 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 236 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
234 237
235 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 238// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 5000 ) ) {
236 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 239// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
237 } else if ( sampleWaitTime <= -5000 ) { 240// }
238 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 241// else if ( sampleWaitTime <= -5000 ) {
239 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 242// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
240 currentSample = sampleWeShouldBeAt; 243// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
241 } 244// currentSample = sampleWeShouldBeAt;
245// }
242 246
243 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 247 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
244 audioSampleCounter = currentSample + samplesRead - 1; 248 audioSampleCounter = currentSample + samplesRead - 1;
@@ -373,23 +377,23 @@ bool LoopControl::init( const QString& filename ) {
373 int astream = 0; 377 int astream = 0;
374 378
375 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 379 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
376 DecodeLoopDebug(( "channels = %d\n", channels )); 380 qDebug( "LC- channels = %d", channels );
377 381
378 if ( !total_audio_samples ) 382 if ( !total_audio_samples )
379 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 383 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
380 384
381 total_audio_samples += 1000; 385// total_audio_samples += 1000;
382 386
383 mediaPlayerState->setLength( total_audio_samples ); 387 mediaPlayerState->setLength( total_audio_samples );
384 388
385 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 389 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
386 DecodeLoopDebug(( "frequency = %d\n", freq )); 390 qDebug( "LC- frequency = %d", freq );
387 391
388 audioSampleCounter = 0; 392 audioSampleCounter = 0;
389 393
390 static const int bytes_per_sample = 2; //16 bit 394 int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream);
391 395
392 audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); 396 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
393 audioBuffer = new char[ audioDevice->bufferSize() ]; 397 audioBuffer = new char[ audioDevice->bufferSize() ];
394 channels = audioDevice->channels(); 398 channels = audioDevice->channels();
395 399