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.cpp353
1 files changed, 176 insertions, 177 deletions
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index dd466ed..90a7cc6 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -1,7 +1,7 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the 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
@@ -17,12 +17,14 @@
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20// L.J.Potter added changes Fri 02-15-2002
21
22
20#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
21#ifdef Q_WS_QWS
22 24
25#ifdef Q_WS_QWS
23#include <qpe/qcopenvelope_qws.h> 26#include <qpe/qcopenvelope_qws.h>
24#endif 27#endif
25#include <qpe/mediaplayerplugininterface.h>
26#include <stdio.h> 28#include <stdio.h>
27#include <stdlib.h> 29#include <stdlib.h>
28#include <string.h> 30#include <string.h>
@@ -32,6 +34,7 @@
32#include "loopcontrol.h" 34#include "loopcontrol.h"
33#include "videowidget.h" 35#include "videowidget.h"
34#include "audiodevice.h" 36#include "audiodevice.h"
37#include "mediaplayerplugininterface.h"
35#include "mediaplayerstate.h" 38#include "mediaplayerstate.h"
36 39
37 40
@@ -43,13 +46,13 @@ extern MediaPlayerState *mediaPlayerState;
43#define DecodeLoopDebug(x) 46#define DecodeLoopDebug(x)
44 47
45 48
46 static char *audioBuffer = NULL; 49static char *audioBuffer = NULL;
47static AudioDevice *audioDevice = NULL; 50static AudioDevice *audioDevice = NULL;
48 static bool disabledSuspendScreenSaver = FALSE; 51static bool disabledSuspendScreenSaver = FALSE;
49 static bool previousSuspendMode = FALSE; 52static bool previousSuspendMode = FALSE;
50 53
51 54
52 pthread_taudio_tid; 55pthread_t audio_tid;
53pthread_attr_t audio_attr; 56pthread_attr_t audio_attr;
54bool threadOkToGo = FALSE; 57bool threadOkToGo = FALSE;
55 58
@@ -57,22 +60,22 @@ bool threadOkToGo = FALSE;
57class Mutex { 60class Mutex {
58public: 61public:
59 Mutex() { 62 Mutex() {
60 pthread_mutexattr_t attr; 63 pthread_mutexattr_t attr;
61 pthread_mutexattr_init( &attr ); 64 pthread_mutexattr_init( &attr );
62 pthread_mutex_init( &mutex, &attr ); 65 pthread_mutex_init( &mutex, &attr );
63 pthread_mutexattr_destroy( &attr ); 66 pthread_mutexattr_destroy( &attr );
64 } 67 }
65 68
66 ~Mutex() { 69 ~Mutex() {
67 pthread_mutex_destroy( &mutex ); 70 pthread_mutex_destroy( &mutex );
68 } 71 }
69 72
70 void lock() { 73 void lock() {
71 pthread_mutex_lock( &mutex ); 74 pthread_mutex_lock( &mutex );
72 } 75 }
73 76
74 void unlock() { 77 void unlock() {
75 pthread_mutex_unlock( &mutex ); 78 pthread_mutex_unlock( &mutex );
76 } 79 }
77private: 80private:
78 pthread_mutex_t mutex; 81 pthread_mutex_t mutex;
@@ -82,10 +85,10 @@ private:
82void *startAudioThread( void *ptr ) { 85void *startAudioThread( void *ptr ) {
83 LoopControl *mpegView = (LoopControl *)ptr; 86 LoopControl *mpegView = (LoopControl *)ptr;
84 while ( TRUE ) { 87 while ( TRUE ) {
85 if ( threadOkToGo && mpegView->moreAudio ) 88 if ( threadOkToGo && mpegView->moreAudio )
86 mpegView->startAudio(); 89 mpegView->startAudio();
87 else 90 else
88 usleep( 10000 ); // Semi-buzy-wait till we are playing again 91 usleep( 10000 ); // Semi-buzy-wait till we are playing again
89 } 92 }
90 return 0; 93 return 0;
91} 94}
@@ -102,24 +105,19 @@ LoopControl::LoopControl( QObject *parent, const char *name )
102 audioMutex = new Mutex; 105 audioMutex = new Mutex;
103 106
104 pthread_attr_init(&audio_attr); 107 pthread_attr_init(&audio_attr);
105 108#define USE_REALTIME_AUDIO_THREAD
106 if ( getuid() == 0 ) { 109#ifdef USE_REALTIME_AUDIO_THREAD
107 printf("true, guid = %i\n", getuid()); 110 // Attempt to set it to real-time round robin
108 111 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) {
109 // Attempt to set it to real-time round robin 112 sched_param params;
110 if ( pthread_attr_setschedpolicy( &audio_attr, SCHED_RR ) == 0 ) { 113 params.sched_priority = 50;
111 sched_param params; 114 pthread_attr_setschedparam(&audio_attr,&params);
112 params.sched_priority = 50; 115 } else {
113 pthread_attr_setschedparam(&audio_attr,&params); 116 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." );
114 } else { 117 pthread_attr_destroy(&audio_attr);
115 qDebug( "Error setting up a realtime thread, reverting to using a normal thread." ); 118 pthread_attr_init(&audio_attr);
116 pthread_attr_destroy(&audio_attr);
117 pthread_attr_init(&audio_attr);
118 }
119 } 119 }
120// printf("false, guid = %i\n", getuid()); 120#endif
121 usleep( 100 );
122
123 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this); 121 pthread_create(&audio_tid, &audio_attr, (void * (*)(void *))startAudioThread, this);
124} 122}
125 123
@@ -136,14 +134,14 @@ static int currentSample = 0;
136void LoopControl::timerEvent( QTimerEvent *te ) { 134void LoopControl::timerEvent( QTimerEvent *te ) {
137 135
138 if ( te->timerId() == videoId ) 136 if ( te->timerId() == videoId )
139 startVideo(); 137 startVideo();
140 138
141 if ( te->timerId() == sliderId ) { 139 if ( te->timerId() == sliderId ) {
142 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { 140 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
143 mediaPlayerState->updatePosition( audioSampleCounter ); 141 mediaPlayerState->updatePosition( audioSampleCounter );
144 } else if ( hasVideoChannel && moreVideo ) { 142 } else if ( hasVideoChannel && moreVideo ) {
145 mediaPlayerState->updatePosition( current_frame ); 143 mediaPlayerState->updatePosition( current_frame );
146 } 144 }
147 } 145 }
148 146
149 if ( !moreVideo && !moreAudio ) { 147 if ( !moreVideo && !moreAudio ) {
@@ -157,26 +155,26 @@ void LoopControl::setPosition( long pos ) {
157 audioMutex->lock(); 155 audioMutex->lock();
158 156
159 if ( hasVideoChannel && hasAudioChannel ) { 157 if ( hasVideoChannel && hasAudioChannel ) {
160 playtime.restart(); 158 playtime.restart();
161 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 159 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
162 current_frame = pos + 1; 160 current_frame = pos + 1;
163 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 161 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
164 prev_frame = current_frame - 1; 162 prev_frame = current_frame - 1;
165 currentSample = (int)( (double)current_frame * freq / framerate ); 163 currentSample = (int)( (double)current_frame * freq / framerate );
166 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 164 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
167 audioSampleCounter = currentSample - 1; 165 audioSampleCounter = currentSample - 1;
168 } else if ( hasVideoChannel ) { 166 } else if ( hasVideoChannel ) {
169 playtime.restart(); 167 playtime.restart();
170 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 168 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
171 current_frame = pos + 1; 169 current_frame = pos + 1;
172 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 170 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
173 prev_frame = current_frame - 1; 171 prev_frame = current_frame - 1;
174 } else if ( hasAudioChannel ) { 172 } else if ( hasAudioChannel ) {
175 playtime.restart(); 173 playtime.restart();
176 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); 174 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
177 currentSample = pos + 1; 175 currentSample = pos + 1;
178 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 176 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
179 audioSampleCounter = currentSample - 1; 177 audioSampleCounter = currentSample - 1;
180 } 178 }
181 179
182 audioMutex->unlock(); 180 audioMutex->unlock();
@@ -189,32 +187,32 @@ void LoopControl::startVideo() {
189 187
190 if ( mediaPlayerState->curDecoder() ) { 188 if ( mediaPlayerState->curDecoder() ) {
191 189
192 if ( hasAudioChannel && !isMuted ) { 190 if ( hasAudioChannel && !isMuted ) {
193 191
194 current_frame = long( playtime.elapsed() * framerate / 1000 ); 192 current_frame = long( playtime.elapsed() * framerate / 1000 );
195 193
196 if ( prev_frame != -1 && current_frame <= prev_frame ) 194 if ( prev_frame != -1 && current_frame <= prev_frame )
197 return; 195 return;
198 196
199 } else { 197 } else {
200 // Don't skip 198 // Don't skip
201 current_frame++; 199 current_frame++;
202 } 200 }
203 201
204 if ( prev_frame == -1 || current_frame > prev_frame ) { 202 if ( prev_frame == -1 || current_frame > prev_frame ) {
205 if ( current_frame > prev_frame + 1 ) { 203 if ( current_frame > prev_frame + 1 ) {
206 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 204 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
207 } 205 }
208 moreVideo = videoUI->playVideo(); 206 moreVideo = videoUI->playVideo();
209 prev_frame = current_frame; 207 prev_frame = current_frame;
210 } 208 }
211 209
212 } else { 210 } else {
213 211
214 moreVideo = FALSE; 212 moreVideo = FALSE;
215 killTimer( videoId ); 213 killTimer( videoId );
216 214
217 } 215 }
218 216
219 } 217 }
220} 218}
@@ -226,36 +224,37 @@ void LoopControl::startAudio() {
226 224
227 if ( moreAudio ) { 225 if ( moreAudio ) {
228 226
229 if ( !isMuted && mediaPlayerState->curDecoder() ) { 227 if ( !isMuted && mediaPlayerState->curDecoder() ) {
230 228
231 currentSample = audioSampleCounter + 1; 229 currentSample = audioSampleCounter + 1;
232 230
233 if ( currentSample != audioSampleCounter + 1 ) 231 if ( currentSample != audioSampleCounter + 1 )
234 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 232 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
235 233
236 long samplesRead = 0; 234 long samplesRead = 0;
237 mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 235 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
238 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 236 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
239 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 237 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
240 238
241 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 239 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
242 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 240 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
243 } else if ( sampleWaitTime <= -5000 ) { 241 }
244 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 242 else if ( sampleWaitTime <= -5000 ) {
245 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 243 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
246 currentSample = sampleWeShouldBeAt; 244 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
247 } 245 currentSample = sampleWeShouldBeAt;
246 }
248 247
249 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 248 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
250 audioSampleCounter = currentSample + samplesRead - 1; 249 audioSampleCounter = currentSample + samplesRead - 1;
251 250
252 moreAudio = audioSampleCounter <= total_audio_samples; 251 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
253 252
254 } else { 253 } else {
255 254
256 moreAudio = FALSE; 255 moreAudio = FALSE;
257 256
258 } 257 }
259 258
260 } 259 }
261 260
@@ -268,7 +267,7 @@ void LoopControl::killTimers() {
268 audioMutex->lock(); 267 audioMutex->lock();
269 268
270 if ( hasVideoChannel ) 269 if ( hasVideoChannel )
271 killTimer( videoId ); 270 killTimer( videoId );
272 killTimer( sliderId ); 271 killTimer( sliderId );
273 threadOkToGo = FALSE; 272 threadOkToGo = FALSE;
274 273
@@ -284,14 +283,14 @@ void LoopControl::startTimers() {
284 moreAudio = FALSE; 283 moreAudio = FALSE;
285 284
286 if ( hasVideoChannel ) { 285 if ( hasVideoChannel ) {
287 moreVideo = TRUE; 286 moreVideo = TRUE;
288 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value 287 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value
289 videoId = startTimer( mSecsBetweenFrames ); 288 videoId = startTimer( mSecsBetweenFrames );
290 } 289 }
291 290
292 if ( hasAudioChannel ) { 291 if ( hasAudioChannel ) {
293 moreAudio = TRUE; 292 moreAudio = TRUE;
294 threadOkToGo = TRUE; 293 threadOkToGo = TRUE;
295 } 294 }
296 295
297 sliderId = startTimer( 300 ); // update slider every 1/3 second 296 sliderId = startTimer( 300 ); // update slider every 1/3 second
@@ -303,16 +302,16 @@ void LoopControl::startTimers() {
303void LoopControl::setPaused( bool pause ) { 302void LoopControl::setPaused( bool pause ) {
304 303
305 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) 304 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
306 return; 305 return;
307 306
308 if ( pause ) { 307 if ( pause ) {
309 killTimers(); 308 killTimers();
310 } else { 309 } else {
311 // Force an update of the position 310 // Force an update of the position
312 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 311 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
313 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 312 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
314 // Just like we never stopped 313 // Just like we never stopped
315 startTimers(); 314 startTimers();
316 } 315 }
317} 316}
318 317
@@ -321,28 +320,28 @@ void LoopControl::stop( bool willPlayAgainShortly ) {
321 320
322#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 321#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
323 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { 322 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
324 disabledSuspendScreenSaver = FALSE; 323 disabledSuspendScreenSaver = FALSE;
325 // Re-enable the suspend mode 324 // Re-enable the suspend mode
326 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 325 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
327 } 326 }
328#endif 327#endif
329 328
330 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { 329 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
331 330
332 killTimers(); 331 killTimers();
333 332
334 audioMutex->lock(); 333 audioMutex->lock();
335 334
336 mediaPlayerState->curDecoder()->close(); 335 mediaPlayerState->curDecoder()->close();
337 336
338 if ( audioDevice ) { 337 if ( audioDevice ) {
339 delete audioDevice; 338 delete audioDevice;
340 delete audioBuffer; 339 delete audioBuffer;
341 audioDevice = 0; 340 audioDevice = 0;
342 audioBuffer = 0; 341 audioBuffer = 0;
343 } 342 }
344 343
345 audioMutex->unlock(); 344 audioMutex->unlock();
346 345
347 } 346 }
348} 347}
@@ -361,67 +360,67 @@ bool LoopControl::init( const QString& filename ) {
361 360
362 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin 361 // ### Hack to use libmpeg3plugin to get the number of audio samples if we are using the libmad plugin
363 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) { 362 if ( mediaPlayerState->curDecoder()->pluginName() == QString("LibMadPlugin") ) {
364 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) { 363 if ( mediaPlayerState->libMpeg3Decoder() && mediaPlayerState->libMpeg3Decoder()->open( filename ) ) {
365 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 ); 364 total_audio_samples = mediaPlayerState->libMpeg3Decoder()->audioSamples( 0 );
366 mediaPlayerState->libMpeg3Decoder()->close(); 365 mediaPlayerState->libMpeg3Decoder()->close();
367 } 366 }
368 } 367 }
369 368
370 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) { 369 if ( !mediaPlayerState->curDecoder()|| !mediaPlayerState->curDecoder()->open( filename ) ) {
371 audioMutex->unlock(); 370 audioMutex->unlock();
372 return FALSE; 371 return FALSE;
373 } 372 }
374 373
375 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0; 374 hasAudioChannel = mediaPlayerState->curDecoder()->audioStreams() > 0;
376 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0; 375 hasVideoChannel = mediaPlayerState->curDecoder()->videoStreams() > 0;
377 376
378 if ( hasAudioChannel ) { 377 if ( hasAudioChannel ) {
379 int astream = 0; 378 int astream = 0;
380 379
381 channels = mediaPlayerState->curDecoder()->audioChannels( astream ); 380 channels = mediaPlayerState->curDecoder()->audioChannels( astream );
382 DecodeLoopDebug(( "channels = %d\n", channels )); 381 qDebug( "LC- channels = %d", channels );
383 382
384 if ( !total_audio_samples ) 383 if ( !total_audio_samples )
385 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream ); 384 total_audio_samples = mediaPlayerState->curDecoder()->audioSamples( astream );
386 385
387 total_audio_samples += 1000; 386// total_audio_samples += 1000;
388 387
389 mediaPlayerState->setLength( total_audio_samples ); 388 mediaPlayerState->setLength( total_audio_samples );
390 389
391 freq = mediaPlayerState->curDecoder()->audioFrequency( astream ); 390 freq = mediaPlayerState->curDecoder()->audioFrequency( astream );
392 DecodeLoopDebug(( "frequency = %d\n", freq )); 391 qDebug( "LC- frequency = %d", freq );
393 392
394 audioSampleCounter = 0; 393 audioSampleCounter = 0;
395 394
396 static const int bytes_per_sample = 2; //16 bit 395 int bits_per_sample = mediaPlayerState->curDecoder()->audioBitsPerSample( astream);
397 396
398 audioDevice = new AudioDevice( freq, channels, bytes_per_sample ); 397 audioDevice = new AudioDevice( freq, channels, bits_per_sample);
399 audioBuffer = new char[ audioDevice->bufferSize() ]; 398 audioBuffer = new char[ audioDevice->bufferSize() ];
400 channels = audioDevice->channels(); 399 channels = audioDevice->channels();
401 400
402 //### must check which frequency is actually used. 401 //### must check which frequency is actually used.
403 static const int size = 1; 402 static const int size = 1;
404 short int buf[size]; 403 short int buf[size];
405 long samplesRead = 0; 404 long samplesRead = 0;
406 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream ); 405 mediaPlayerState->curDecoder()->audioReadSamples( buf, channels, size, samplesRead, stream );
407 } 406 }
408 407
409 if ( hasVideoChannel ) { 408 if ( hasVideoChannel ) {
410 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream ); 409 total_video_frames = mediaPlayerState->curDecoder()->videoFrames( stream );
411 410
412 mediaPlayerState->setLength( total_video_frames ); 411 mediaPlayerState->setLength( total_video_frames );
413 412
414 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream ); 413 framerate = mediaPlayerState->curDecoder()->videoFrameRate( stream );
415 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames )); 414 DecodeLoopDebug(( "Frame rate %g total %ld", framerate, total_video_frames ));
416 415
417 if ( framerate <= 1.0 ) { 416 if ( framerate <= 1.0 ) {
418 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" )); 417 DecodeLoopDebug(( "Crazy frame rate, resetting to sensible" ));
419 framerate = 25; 418 framerate = 25;
420 } 419 }
421 420
422 if ( total_video_frames == 1 ) { 421 if ( total_video_frames == 1 ) {
423 DecodeLoopDebug(( "Cannot seek to frame" )); 422 DecodeLoopDebug(( "Cannot seek to frame" ));
424 } 423 }
425 424
426 } 425 }
427 426
@@ -441,11 +440,11 @@ void LoopControl::play() {
441 440
442#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 441#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
443 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) { 442 if ( !disabledSuspendScreenSaver || previousSuspendMode != hasVideoChannel ) {
444 disabledSuspendScreenSaver = TRUE; 443 disabledSuspendScreenSaver = TRUE;
445 previousSuspendMode = hasVideoChannel; 444 previousSuspendMode = hasVideoChannel;
446 // Stop the screen from blanking and power saving state 445 // Stop the screen from blanking and power saving state
447 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) 446 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" )
448 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend ); 447 << ( hasVideoChannel ? QPEApplication::Disable : QPEApplication::DisableSuspend );
449 } 448 }
450#endif 449#endif
451 450
@@ -456,14 +455,14 @@ void LoopControl::play() {
456 455
457void LoopControl::setMute( bool on ) { 456void LoopControl::setMute( bool on ) {
458 if ( on != isMuted ) { 457 if ( on != isMuted ) {
459 isMuted = on; 458 isMuted = on;
460 if ( !on ) { 459 if ( !on ) {
461 // Force an update of the position 460 // Force an update of the position
462 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 461 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
463 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 462 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
464 // Resume playing audio 463 // Resume playing audio
465 moreAudio = TRUE; 464 moreAudio = TRUE;
466 } 465 }
467 } 466 }
468} 467}
469 468