Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 90a7cc6..cb8de8a 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -35,5 +35,5 @@ | |||
35 | #include "videowidget.h" | 35 | #include "videowidget.h" |
36 | #include "audiodevice.h" | 36 | #include "audiodevice.h" |
37 | #include "mediaplayerplugininterface.h" | 37 | #include <qpe/mediaplayerplugininterface.h> |
38 | #include "mediaplayerstate.h" | 38 | #include "mediaplayerstate.h" |
39 | 39 | ||
@@ -102,5 +102,5 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
102 | isMuted = FALSE; | 102 | isMuted = FALSE; |
103 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); | 103 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); |
104 | 104 | //qDebug("starting loopcontrol"); | |
105 | audioMutex = new Mutex; | 105 | audioMutex = new Mutex; |
106 | 106 | ||
@@ -119,4 +119,5 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
119 | } | 119 | } |
120 | #endif | 120 | #endif |
121 | //qDebug("create audio thread"); | ||
121 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 122 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
122 | } | 123 | } |
@@ -221,6 +222,6 @@ void LoopControl::startVideo() { | |||
221 | void LoopControl::startAudio() { | 222 | void LoopControl::startAudio() { |
222 | 223 | ||
224 | //qDebug("start audio"); | ||
223 | audioMutex->lock(); | 225 | audioMutex->lock(); |
224 | |||
225 | if ( moreAudio ) { | 226 | if ( moreAudio ) { |
226 | 227 | ||
@@ -237,12 +238,12 @@ void LoopControl::startAudio() { | |||
237 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; | 238 | long sampleWaitTime = currentSample - sampleWeShouldBeAt; |
238 | 239 | ||
239 | if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { | 240 | // if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { |
240 | usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); | 241 | // usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); |
241 | } | 242 | // } |
242 | else if ( sampleWaitTime <= -5000 ) { | 243 | // else if ( sampleWaitTime <= -5000 ) { |
243 | qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 244 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); |
244 | //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 245 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
245 | currentSample = sampleWeShouldBeAt; | 246 | // currentSample = sampleWeShouldBeAt; |
246 | } | 247 | // } |
247 | 248 | ||
248 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); | 249 | audioDevice->write( audioBuffer, samplesRead * 2 * channels ); |
@@ -392,6 +393,11 @@ bool LoopControl::init( const QString& filename ) { | |||
392 | 393 | ||
393 | audioSampleCounter = 0; | 394 | audioSampleCounter = 0; |
394 | 395 | int bits_per_sample; | |
395 | int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream); | 396 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { |
397 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); | ||
398 | qDebug("using stupid hack"); | ||
399 | } else { | ||
400 | bits_per_sample=0; | ||
401 | } | ||
396 | 402 | ||
397 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); | 403 | audioDevice = new AudioDevice( freq, channels, bits_per_sample); |
@@ -438,5 +444,5 @@ bool LoopControl::init( const QString& filename ) { | |||
438 | 444 | ||
439 | void LoopControl::play() { | 445 | void LoopControl::play() { |
440 | 446 | qDebug("LC- play"); | |
441 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 447 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
442 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 448 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |