Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | core/multimedia/opieplayer/loopcontrol.cpp | 68 |
1 files changed, 38 insertions, 30 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp index 4ed5921..91153fd 100644 --- a/core/multimedia/opieplayer/loopcontrol.cpp +++ b/core/multimedia/opieplayer/loopcontrol.cpp | |||
@@ -20,9 +20,22 @@ | |||
20 | // L.J.Potter added changes Fri 02-15-2002 | 20 | // L.J.Potter added changes Fri 02-15-2002 |
21 | 21 | ||
22 | |||
23 | #include "mediaplayerstate.h" | ||
24 | #include "loopcontrol.h" | ||
25 | #include "videowidget.h" | ||
26 | #include "audiodevice.h" | ||
27 | |||
28 | /* OPIE */ | ||
22 | #include <qpe/qpeapplication.h> | 29 | #include <qpe/qpeapplication.h> |
30 | #include <qpe/mediaplayerplugininterface.h> | ||
31 | #include <opie2/odebug.h> | ||
23 | 32 | ||
24 | #ifdef Q_WS_QWS | 33 | #ifdef Q_WS_QWS |
25 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
26 | #endif | 35 | #endif |
36 | |||
37 | /* QT */ | ||
38 | |||
39 | /* STD */ | ||
27 | #include <stdio.h> | 40 | #include <stdio.h> |
28 | #include <stdlib.h> | 41 | #include <stdlib.h> |
@@ -31,9 +44,4 @@ | |||
31 | #include <errno.h> | 44 | #include <errno.h> |
32 | #include <unistd.h> | 45 | #include <unistd.h> |
33 | #include "loopcontrol.h" | ||
34 | #include "videowidget.h" | ||
35 | #include "audiodevice.h" | ||
36 | #include <qpe/mediaplayerplugininterface.h> | ||
37 | #include "mediaplayerstate.h" | ||
38 | 46 | ||
39 | 47 | ||
@@ -101,5 +109,5 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
101 | isMuted = FALSE; | 109 | isMuted = FALSE; |
102 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); | 110 | connect( qApp, SIGNAL( volumeChanged(bool) ), this, SLOT( setMute(bool) ) ); |
103 | //qDebug("starting loopcontrol"); | 111 | //odebug << "starting loopcontrol" << oendl; |
104 | audioMutex = new Mutex; | 112 | audioMutex = new Mutex; |
105 | 113 | ||
@@ -113,10 +121,10 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
113 | pthread_attr_setschedparam(&audio_attr,¶ms); | 121 | pthread_attr_setschedparam(&audio_attr,¶ms); |
114 | } else { | 122 | } else { |
115 | // qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); | 123 | // odebug << "Error setting up a realtime thread, reverting to using a normal thread." << oendl; |
116 | pthread_attr_destroy(&audio_attr); | 124 | pthread_attr_destroy(&audio_attr); |
117 | pthread_attr_init(&audio_attr); | 125 | pthread_attr_init(&audio_attr); |
118 | } | 126 | } |
119 | #endif | 127 | #endif |
120 | //qDebug("create audio thread"); | 128 | //odebug << "create audio thread" << oendl; |
121 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); | 129 | pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); |
122 | } | 130 | } |
@@ -145,5 +153,5 @@ void LoopControl::timerEvent( QTimerEvent *te ) { | |||
145 | } | 153 | } |
146 | 154 | ||
147 | if ( !moreVideo && !moreAudio ) { | 155 | if ( !moreVideo && !moreAudio ) { |
148 | mediaPlayerState->setPlaying( FALSE ); | 156 | mediaPlayerState->setPlaying( FALSE ); |
149 | mediaPlayerState->setNext(); | 157 | mediaPlayerState->setNext(); |
@@ -154,5 +162,5 @@ void LoopControl::timerEvent( QTimerEvent *te ) { | |||
154 | void LoopControl::setPosition( long pos ) { | 162 | void LoopControl::setPosition( long pos ) { |
155 | audioMutex->lock(); | 163 | audioMutex->lock(); |
156 | // qDebug("Loop control %d", pos); | 164 | // odebug << "Loop control " << pos << "" << oendl; |
157 | if ( hasVideoChannel && hasAudioChannel ) { | 165 | if ( hasVideoChannel && hasAudioChannel ) { |
158 | playtime.restart(); | 166 | playtime.restart(); |
@@ -220,5 +228,5 @@ void LoopControl::startVideo() { | |||
220 | 228 | ||
221 | void LoopControl::startAudio() { | 229 | void LoopControl::startAudio() { |
222 | 230 | ||
223 | audioMutex->lock(); | 231 | audioMutex->lock(); |
224 | if ( moreAudio ) { | 232 | if ( moreAudio ) { |
@@ -229,5 +237,5 @@ void LoopControl::startAudio() { | |||
229 | 237 | ||
230 | // if ( currentSample != audioSampleCounter + 1 ) | 238 | // if ( currentSample != audioSampleCounter + 1 ) |
231 | // qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); | 239 | // odebug << "out of sync with decoder " << currentSample << " " << audioSampleCounter << "" << oendl; |
232 | 240 | ||
233 | long samplesRead = 0; | 241 | long samplesRead = 0; |
@@ -242,5 +250,5 @@ void LoopControl::startAudio() { | |||
242 | } | 250 | } |
243 | else if ( sampleWaitTime <= -5000 ) { | 251 | else if ( sampleWaitTime <= -5000 ) { |
244 | // qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); | 252 | // odebug << "need to catch up by: " << -sampleWaitTime << " (" << currentSample << "," << sampleWeShouldBeAt << ")" << oendl; |
245 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); | 253 | // //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); |
246 | currentSample = sampleWeShouldBeAt; | 254 | currentSample = sampleWeShouldBeAt; |
@@ -271,5 +279,5 @@ void LoopControl::killTimers() { | |||
271 | audioMutex->lock(); | 279 | audioMutex->lock(); |
272 | 280 | ||
273 | if ( hasVideoChannel ) | 281 | if ( hasVideoChannel ) |
274 | killTimer( videoId ); | 282 | killTimer( videoId ); |
275 | killTimer( sliderId ); | 283 | killTimer( sliderId ); |
@@ -325,5 +333,5 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
325 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 333 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
326 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { | 334 | if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { |
327 | disabledSuspendScreenSaver = FALSE; | 335 | disabledSuspendScreenSaver = FALSE; |
328 | // Re-enable the suspend mode | 336 | // Re-enable the suspend mode |
329 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 337 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
@@ -350,5 +358,5 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
350 | audioSampleCounter=0; | 358 | audioSampleCounter=0; |
351 | current_frame=0; | 359 | current_frame=0; |
352 | total_audio_samples=0; | 360 | total_audio_samples=0; |
353 | } | 361 | } |
354 | 362 | ||
@@ -361,7 +369,7 @@ bool LoopControl::init( const QString& filename ) { | |||
361 | stream = 0; // only play stream 0 for now | 369 | stream = 0; // only play stream 0 for now |
362 | current_frame = total_video_frames = total_audio_samples = 0; | 370 | current_frame = total_video_frames = total_audio_samples = 0; |
363 | 371 | ||
364 | // qDebug( "Using the %s decoder", mediaPlayerState->curDecoder()->pluginName() ); | 372 | // odebug << "Using the " << mediaPlayerState->curDecoder()->pluginName() << " decoder" << oendl; |
365 | 373 | ||
366 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin | 374 | // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin |
367 | // if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { | 375 | // if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { |
@@ -371,5 +379,5 @@ bool LoopControl::init( const QString& filename ) { | |||
371 | // } | 379 | // } |
372 | // } | 380 | // } |
373 | 381 | ||
374 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 382 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
375 | audioMutex->unlock(); | 383 | audioMutex->unlock(); |
@@ -388,15 +396,15 @@ bool LoopControl::init( const QString& filename ) { | |||
388 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); | 396 | channels = mediaPlayerState->curDecoder()->audioChannels( astream ); |
389 | 397 | ||
390 | // qDebug( "LC- channels = %d", channels ); | 398 | // odebug << "LC- channels = " << channels << "" << oendl; |
391 | 399 | ||
392 | // if ( !total_audio_samples ) | 400 | // if ( !total_audio_samples ) |
393 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); | 401 | total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); |
394 | 402 | ||
395 | total_audio_samples += 1000; | 403 | total_audio_samples += 1000; |
396 | // qDebug("total samples %d", total_audio_samples); | 404 | // odebug << "total samples " << total_audio_samples << "" << oendl; |
397 | mediaPlayerState->setLength( total_audio_samples ); | 405 | mediaPlayerState->setLength( total_audio_samples ); |
398 | 406 | ||
399 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); | 407 | freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); |
400 | // qDebug( "LC- frequency = %d", freq ); | 408 | // odebug << "LC- frequency = " << freq << "" << oendl; |
401 | 409 | ||
402 | audioSampleCounter = 0; | 410 | audioSampleCounter = 0; |
@@ -404,5 +412,5 @@ bool LoopControl::init( const QString& filename ) { | |||
404 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { | 412 | if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibWavPlugin") ) { |
405 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); | 413 | bits_per_sample =(int) mediaPlayerState->curDecoder()->getTime(); |
406 | // qDebug("using stupid hack"); | 414 | // odebug << "using stupid hack" << oendl; |
407 | } else { | 415 | } else { |
408 | bits_per_sample=0; | 416 | bits_per_sample=0; |
@@ -452,13 +460,13 @@ bool LoopControl::init( const QString& filename ) { | |||
452 | 460 | ||
453 | void LoopControl::play() { | 461 | void LoopControl::play() { |
454 | // qDebug("LC- play"); | 462 | // odebug << "LC- play" << oendl; |
455 | mediaPlayerState->setPosition( 0); //uglyhack | 463 | mediaPlayerState->setPosition( 0); //uglyhack |
456 | 464 | ||
457 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 465 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
458 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { | 466 | if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { |
459 | disabledSuspendScreenSaver = TRUE; | 467 | disabledSuspendScreenSaver = TRUE; |
460 | previousSuspendMode = hasVideoChannel; | 468 | previousSuspendMode = hasVideoChannel; |
461 | // Stop the screen from blanking and power saving state | 469 | // Stop the screen from blanking and power saving state |
462 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) | 470 | QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) |
463 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); | 471 | << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); |
464 | } | 472 | } |