summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol.cpp
authorllornkcor <llornkcor>2002-04-21 03:26:09 (UTC)
committer llornkcor <llornkcor>2002-04-21 03:26:09 (UTC)
commit6818807a46b80774de328b4c3001d4bc9d788666 (patch) (unidiff)
tree1bede7ebbb324058b664330abf481f7afb25eb73 /core/multimedia/opieplayer/loopcontrol.cpp
parent1c459273c0e9e387fd5fe2e2c05bef4db5bce115 (diff)
downloadopie-6818807a46b80774de328b4c3001d4bc9d788666.zip
opie-6818807a46b80774de328b4c3001d4bc9d788666.tar.gz
opie-6818807a46b80774de328b4c3001d4bc9d788666.tar.bz2
fixed when playing stream, slider moved and stopped stream when it reached the end
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index b9f96de..45c2d3e 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -233,20 +233,21 @@ void LoopControl::startAudio() {
233 233
234 long samplesRead = 0; 234 long samplesRead = 0;
235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
237 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 237 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
238 238
239// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 239// this causes drop outs not sure why its even here
240// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 240// if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
241// usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
242// }
243// else if ( sampleWaitTime <= -5000 ) {
244// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
245// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
246// currentSample = sampleWeShouldBeAt;
241// } 247// }
242// else if ( sampleWaitTime <= -5000 ) {
243// qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
244// //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
245// currentSample = sampleWeShouldBeAt;
246// }
247 248
248 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 249 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
249 audioSampleCounter = currentSample + samplesRead - 1; 250 audioSampleCounter = currentSample + samplesRead - 1;
250 251
251 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 252 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
252 253
@@ -429,12 +430,15 @@ bool LoopControl::init( const QString& filename ) {
429 430
430 } 431 }
431 432
432 current_frame = 0; 433 current_frame = 0;
433 prev_frame = -1; 434 prev_frame = -1;
434 435
436 if( fileName.left(7) == "http://")
437 mediaPlayerState->isStreaming = TRUE;
438
435 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) ); 439 connect( mediaPlayerState, SIGNAL( positionChanged( long ) ), this, SLOT( setPosition( long ) ) );
436 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) ); 440 connect( mediaPlayerState, SIGNAL( pausedToggled( bool ) ), this, SLOT( setPaused( bool ) ) );
437 441
438 audioMutex->unlock(); 442 audioMutex->unlock();
439 443
440 return TRUE; 444 return TRUE;