summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp34
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
@@ -34,7 +34,7 @@
34#include "loopcontrol.h" 34#include "loopcontrol.h"
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
40 40
@@ -101,7 +101,7 @@ LoopControl::LoopControl( QObject *parent, const char *name )
101 : QObject( parent, name ) { 101 : QObject( parent, 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
107 pthread_attr_init(&audio_attr); 107 pthread_attr_init(&audio_attr);
@@ -118,6 +118,7 @@ LoopControl::LoopControl( QObject *parent, const char *name )
118 pthread_attr_init(&audio_attr); 118 pthread_attr_init(&audio_attr);
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}
123 124
@@ -220,8 +221,8 @@ void LoopControl::startVideo() {
220 221
221void LoopControl::startAudio() { 222void LoopControl::startAudio() {
222 223
224//qDebug("start audio");
223 audioMutex->lock(); 225 audioMutex->lock();
224
225 if ( moreAudio ) { 226 if ( moreAudio ) {
226 227
227 if ( !isMuted && mediaPlayerState->curDecoder() ) { 228 if ( !isMuted && mediaPlayerState->curDecoder() ) {
@@ -236,14 +237,14 @@ void LoopControl::startAudio() {
236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 237 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
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 );
249 audioSampleCounter = currentSample + samplesRead - 1; 250 audioSampleCounter = currentSample + samplesRead - 1;
@@ -391,8 +392,13 @@ bool LoopControl::init( const QString& filename ) {
391 qDebug( "LC- frequency = %d", freq ); 392 qDebug( "LC- frequency = %d", freq );
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);
398 audioBuffer = new char[ audioDevice->bufferSize() ]; 404 audioBuffer = new char[ audioDevice->bufferSize() ];
@@ -437,7 +443,7 @@ bool LoopControl::init( const QString& filename ) {
437 443
438 444
439void LoopControl::play() { 445void 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 ) {
443 disabledSuspendScreenSaver = TRUE; 449 disabledSuspendScreenSaver = TRUE;