summaryrefslogtreecommitdiff
path: root/core/multimedia/opieplayer/loopcontrol.cpp
Unidiff
Diffstat (limited to 'core/multimedia/opieplayer/loopcontrol.cpp') (more/less context) (show whitespace changes)
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp42
1 files changed, 25 insertions, 17 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
@@ -1,61 +1,69 @@
1/********************************************************************** 1/**********************************************************************
2 ** Copyright (C) 2000 Trolltech AS. All rights reserved. 2 ** Copyright (C) 2000 Trolltech AS. All rights reserved.
3 ** 3 **
4 ** This file is part of Qtopia Environment. 4 ** This file is part of Qtopia Environment.
5 ** 5 **
6 ** This file may be distributed and/or modified under the terms of the 6 ** This file may be distributed and/or modified under the terms of the
7 ** GNU General Public License version 2 as published by the Free Software 7 ** GNU General Public License version 2 as published by the Free Software
8 ** Foundation and appearing in the file LICENSE.GPL included in the 8 ** Foundation and appearing in the file LICENSE.GPL included in the
9 ** packaging of this file. 9 ** packaging of this file.
10 ** 10 **
11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13 ** 13 **
14 ** See http://www.trolltech.com/gpl/ for GPL licensing information. 14 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
15 ** 15 **
16 ** Contact info@trolltech.com if any conditions of this licensing are 16 ** Contact info@trolltech.com if any conditions of this licensing are
17 ** not clear to you. 17 ** not clear to you.
18 ** 18 **
19 **********************************************************************/ 19 **********************************************************************/
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>
29#include <string.h> 42#include <string.h>
30#include <pthread.h> 43#include <pthread.h>
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
40extern VideoWidget *videoUI; // now only needed to tell it to play a frame 48extern VideoWidget *videoUI; // now only needed to tell it to play a frame
41extern MediaPlayerState *mediaPlayerState; 49extern MediaPlayerState *mediaPlayerState;
42 50
43 51
44//#define DecodeLoopDebug(x) qDebug x 52//#define DecodeLoopDebug(x) qDebug x
45#define DecodeLoopDebug(x) 53#define DecodeLoopDebug(x)
46 54
47 55
48static char *audioBuffer = NULL; 56static char *audioBuffer = NULL;
49static AudioDevice *audioDevice = NULL; 57static AudioDevice *audioDevice = NULL;
50static bool disabledSuspendScreenSaver = FALSE; 58static bool disabledSuspendScreenSaver = FALSE;
51static bool previousSuspendMode = FALSE; 59static bool previousSuspendMode = FALSE;
52 60
53 61
54pthread_t audio_tid; 62pthread_t audio_tid;
55pthread_attr_t audio_attr; 63pthread_attr_t audio_attr;
56bool threadOkToGo = FALSE; 64bool threadOkToGo = FALSE;
57 65
58 66
59class Mutex { 67class Mutex {
60public: 68public:
61 Mutex() { 69 Mutex() {
@@ -79,102 +87,102 @@ public:
79private: 87private:
80 pthread_mutex_t mutex; 88 pthread_mutex_t mutex;
81}; 89};
82 90
83 91
84void *startAudioThread( void *ptr ) { 92void *startAudioThread( void *ptr ) {
85 LoopControl *mpegView = (LoopControl *)ptr; 93 LoopControl *mpegView = (LoopControl *)ptr;
86 while ( TRUE ) { 94 while ( TRUE ) {
87 if ( threadOkToGo && mpegView->moreAudio ) 95 if ( threadOkToGo && mpegView->moreAudio )
88 mpegView->startAudio(); 96 mpegView->startAudio();
89 else 97 else
90 usleep( 10000 ); // Semi-buzy-wait till we are playing again 98 usleep( 10000 ); // Semi-buzy-wait till we are playing again
91 } 99 }
92 return 0; 100 return 0;
93} 101}
94 102
95 103
96Mutex *audioMutex; 104Mutex *audioMutex;
97 105
98 106
99LoopControl::LoopControl( QObject *parent, const char *name ) 107LoopControl::LoopControl( QObject *parent, const char *name )
100 : QObject( parent, name ) { 108 : QObject( parent, 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
106 pthread_attr_init(&audio_attr); 114 pthread_attr_init(&audio_attr);
107#define USE_REALTIME_AUDIO_THREAD 115#define USE_REALTIME_AUDIO_THREAD
108#ifdef USE_REALTIME_AUDIO_THREAD 116#ifdef USE_REALTIME_AUDIO_THREAD
109 // Attempt to set it to real-time round robin 117 // Attempt to set it to real-time round robin
110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { 118 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
111 sched_param params; 119 sched_param params;
112 params.sched_priority = 50; 120 params.sched_priority = 50;
113 pthread_attr_setschedparam(&audio_attr,&params); 121 pthread_attr_setschedparam(&audio_attr,&params);
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}
123 131
124 132
125LoopControl::~LoopControl() { 133LoopControl::~LoopControl() {
126 stop(); 134 stop();
127} 135}
128 136
129 137
130static long prev_frame = 0; 138static long prev_frame = 0;
131static int currentSample = 0; 139static int currentSample = 0;
132 140
133 141
134void LoopControl::timerEvent( QTimerEvent *te ) { 142void LoopControl::timerEvent( QTimerEvent *te ) {
135 143
136 if ( te->timerId() == videoId ) 144 if ( te->timerId() == videoId )
137 startVideo(); 145 startVideo();
138 146
139 if ( te->timerId() == sliderId ) { 147 if ( te->timerId() == sliderId ) {
140 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { 148 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
141 mediaPlayerState->updatePosition( audioSampleCounter ); 149 mediaPlayerState->updatePosition( audioSampleCounter );
142 } else if ( hasVideoChannel && moreVideo ) { 150 } else if ( hasVideoChannel && moreVideo ) {
143 mediaPlayerState->updatePosition( current_frame ); 151 mediaPlayerState->updatePosition( current_frame );
144 } 152 }
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();
150 } 158 }
151} 159}
152 160
153 161
154void LoopControl::setPosition( long pos ) { 162void 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();
159 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 167 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
160 current_frame = pos + 1; 168 current_frame = pos + 1;
161 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 169 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
162 prev_frame = current_frame - 1; 170 prev_frame = current_frame - 1;
163 currentSample = (int)( (double)current_frame * freq / framerate ); 171 currentSample = (int)( (double)current_frame * freq / framerate );
164 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 172 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
165 audioSampleCounter = currentSample - 1; 173 audioSampleCounter = currentSample - 1;
166 } else if ( hasVideoChannel ) { 174 } else if ( hasVideoChannel ) {
167 playtime.restart(); 175 playtime.restart();
168 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 176 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
169 current_frame = pos + 1; 177 current_frame = pos + 1;
170 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 178 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
171 prev_frame = current_frame - 1; 179 prev_frame = current_frame - 1;
172 } else if ( hasAudioChannel ) { 180 } else if ( hasAudioChannel ) {
173 playtime.restart(); 181 playtime.restart();
174 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); 182 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
175 currentSample = pos + 1; 183 currentSample = pos + 1;
176 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 184 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
177 audioSampleCounter = currentSample - 1; 185 audioSampleCounter = currentSample - 1;
178 } 186 }
179 187
180 audioMutex->unlock(); 188 audioMutex->unlock();
@@ -207,62 +215,62 @@ void LoopControl::startVideo() {
207 prev_frame = current_frame; 215 prev_frame = current_frame;
208 } 216 }
209 217
210 } else { 218 } else {
211 219
212 moreVideo = FALSE; 220 moreVideo = FALSE;
213 killTimer( videoId ); 221 killTimer( videoId );
214 222
215 } 223 }
216 224
217 } 225 }
218} 226}
219 227
220 228
221void LoopControl::startAudio() { 229void LoopControl::startAudio() {
222 230
223 audioMutex->lock(); 231 audioMutex->lock();
224 if ( moreAudio ) { 232 if ( moreAudio ) {
225 233
226 if ( !isMuted && mediaPlayerState->curDecoder() ) { 234 if ( !isMuted && mediaPlayerState->curDecoder() ) {
227 235
228 currentSample = audioSampleCounter + 1; 236 currentSample = audioSampleCounter + 1;
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;
234 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 242 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
235 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 243 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
236 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 244 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
237 245
238// this causes drop outs not sure why its even here 246// this causes drop outs not sure why its even here
239 if ( hasVideoChannel ) { 247 if ( hasVideoChannel ) {
240 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 248 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
241 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 249 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
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;
247 } 255 }
248} 256}
249 257
250 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 258 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
251 259
252 if( mediaPlayerState->isStreaming == FALSE) 260 if( mediaPlayerState->isStreaming == FALSE)
253 audioSampleCounter = currentSample + samplesRead - 1; 261 audioSampleCounter = currentSample + samplesRead - 1;
254 262
255 moreAudio = readOk && (audioSampleCounter <= total_audio_samples); 263 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
256 264
257 } else { 265 } else {
258 266
259 moreAudio = FALSE; 267 moreAudio = FALSE;
260 268
261 } 269 }
262 270
263 } 271 }
264 272
265 audioMutex->unlock(); 273 audioMutex->unlock();
266} 274}
267 275
268 276
@@ -340,139 +348,139 @@ void LoopControl::stop( bool willPlayAgainShortly ) {
340 348
341 if ( audioDevice ) { 349 if ( audioDevice ) {
342 delete audioDevice; 350 delete audioDevice;
343 delete audioBuffer; 351 delete audioBuffer;
344 audioDevice = 0; 352 audioDevice = 0;
345 audioBuffer = 0; 353 audioBuffer = 0;
346 } 354 }
347 355
348 audioMutex->unlock(); 356 audioMutex->unlock();
349 } 357 }
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
355 363
356bool LoopControl::init( const QString& filename ) { 364bool LoopControl::init( const QString& filename ) {
357 stop(); 365 stop();
358 audioMutex->lock(); 366 audioMutex->lock();
359 367
360 fileName = filename; 368 fileName = 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") ) {
368// if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) { 376// if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename )) {
369// total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 377// total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
370// mediaPlayerState->libMpeg3Decoder()->close(); 378// mediaPlayerState->libMpeg3Decoder()->close();
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();
376 return FALSE; 384 return FALSE;
377 } 385 }
378 386
379 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 387 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
380 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 388 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
381 389
382 if ( hasAudioChannel ) { 390 if ( hasAudioChannel ) {
383 int astream = 0; 391 int astream = 0;
384 392
385 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") ) 393 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMpeg3Plugin") )
386 channels = 2; //dont akx me why, but it needs this hack 394 channels = 2; //dont akx me why, but it needs this hack
387 else 395 else
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;
403 int bits_per_sample; 411 int bits_per_sample;
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;
409 } 417 }
410 418
411 audioDevice = new AudioDevice( freq, channels, bits_per_sample); 419 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
412 audioBuffer = new char[ audioDevice->bufferSize() ]; 420 audioBuffer = new char[ audioDevice->bufferSize() ];
413 channels = audioDevice->channels(); 421 channels = audioDevice->channels();
414 422
415 //### must check which frequency is actually used. 423 //### must check which frequency is actually used.
416 static const int size = 1; 424 static const int size = 1;
417 short int buf[size]; 425 short int buf[size];
418 long samplesRead = 0; 426 long samplesRead = 0;
419 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 427 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
420 } 428 }
421 429
422 if ( hasVideoChannel ) { 430 if ( hasVideoChannel ) {
423 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 431 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
424 432
425 mediaPlayerState->setLength( total_video_frames ); 433 mediaPlayerState->setLength( total_video_frames );
426 434
427 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 435 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
428 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 436 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
429 437
430 if ( framerate <= 1.0 ) { 438 if ( framerate <= 1.0 ) {
431 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 439 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
432 framerate = 25; 440 framerate = 25;
433 } 441 }
434 442
435 if ( total_video_frames == 1 ) { 443 if ( total_video_frames == 1 ) {
436 DecodeLoopDebug(( "Cannot seek to frame" )); 444 DecodeLoopDebug(( "Cannot seek to frame" ));
437 } 445 }
438 446
439 } 447 }
440 448
441 current_frame = 0; 449 current_frame = 0;
442 prev_frame = -1; 450 prev_frame = -1;
443 451
444 connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) ); 452 connect( mediaPlayerState, SIGNAL( positionChanged(long) ), this, SLOT( setPosition(long) ) );
445 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) ); 453 connect( mediaPlayerState, SIGNAL( pausedToggled(bool) ), this, SLOT( setPaused(bool) ) );
446 454
447 audioMutex->unlock(); 455 audioMutex->unlock();
448 456
449 return TRUE; 457 return TRUE;
450} 458}
451 459
452 460
453void LoopControl::play() { 461void 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 }
465#endif 473#endif
466 474
467 playtime.start(); 475 playtime.start();
468 startTimers(); 476 startTimers();
469} 477}
470 478
471 479
472void LoopControl::setMute( bool on ) { 480void LoopControl::setMute( bool on ) {
473 if ( on != isMuted ) { 481 if ( on != isMuted ) {
474 isMuted = on; 482 isMuted = on;
475 if ( !on ) { 483 if ( !on ) {
476 // Force an update of the position 484 // Force an update of the position
477 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 485 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
478 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 486 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );