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 | |||
@@ -21,3 +21,12 @@ | |||
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 | ||
@@ -26,2 +35,6 @@ | |||
26 | #endif | 35 | #endif |
36 | |||
37 | /* QT */ | ||
38 | |||
39 | /* STD */ | ||
27 | #include <stdio.h> | 40 | #include <stdio.h> |
@@ -32,7 +45,2 @@ | |||
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 | ||
@@ -102,3 +110,3 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
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; |
@@ -114,3 +122,3 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
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); |
@@ -119,3 +127,3 @@ LoopControl::LoopControl( QObject *parent, const char *name ) | |||
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); |
@@ -146,3 +154,3 @@ void LoopControl::timerEvent( QTimerEvent *te ) { | |||
146 | 154 | ||
147 | if ( !moreVideo && !moreAudio ) { | 155 | if ( !moreVideo && !moreAudio ) { |
148 | mediaPlayerState->setPlaying( FALSE ); | 156 | mediaPlayerState->setPlaying( FALSE ); |
@@ -155,3 +163,3 @@ 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 ) { |
@@ -221,3 +229,3 @@ void LoopControl::startVideo() { | |||
221 | void LoopControl::startAudio() { | 229 | void LoopControl::startAudio() { |
222 | 230 | ||
223 | audioMutex->lock(); | 231 | audioMutex->lock(); |
@@ -230,3 +238,3 @@ void LoopControl::startAudio() { | |||
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 | ||
@@ -243,3 +251,3 @@ void LoopControl::startAudio() { | |||
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 ); |
@@ -272,3 +280,3 @@ void LoopControl::killTimers() { | |||
272 | 280 | ||
273 | if ( hasVideoChannel ) | 281 | if ( hasVideoChannel ) |
274 | killTimer( videoId ); | 282 | killTimer( videoId ); |
@@ -326,3 +334,3 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
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 |
@@ -351,3 +359,3 @@ void LoopControl::stop( bool willPlayAgainShortly ) { | |||
351 | current_frame=0; | 359 | current_frame=0; |
352 | total_audio_samples=0; | 360 | total_audio_samples=0; |
353 | } | 361 | } |
@@ -362,5 +370,5 @@ bool LoopControl::init( const QString& filename ) { | |||
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 |
@@ -372,3 +380,3 @@ bool LoopControl::init( const QString& filename ) { | |||
372 | // } | 380 | // } |
373 | 381 | ||
374 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { | 382 | if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { |
@@ -389,4 +397,4 @@ bool LoopControl::init( const QString& filename ) { | |||
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 ) |
@@ -395,7 +403,7 @@ bool LoopControl::init( const QString& filename ) { | |||
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 | ||
@@ -405,3 +413,3 @@ bool LoopControl::init( const QString& filename ) { | |||
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 { |
@@ -453,11 +461,11 @@ bool LoopControl::init( const QString& filename ) { | |||
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 ); |