summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/libmad/libmadplugin.cpp8
-rw-r--r--core/multimedia/opieplayer/loopcontrol.cpp4
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.cpp2
3 files changed, 7 insertions, 7 deletions
diff --git a/core/multimedia/opieplayer/libmad/libmadplugin.cpp b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
index b2b876f..9d04f7e 100644
--- a/core/multimedia/opieplayer/libmad/libmadplugin.cpp
+++ b/core/multimedia/opieplayer/libmad/libmadplugin.cpp
@@ -400,179 +400,179 @@ static const int shift = MAD_F_FRACBITS + 1 - bits;
400 400
401inline long audio_linear_dither( mad_fixed_t sample, mad_fixed_t& error ) 401inline long audio_linear_dither( mad_fixed_t sample, mad_fixed_t& error )
402{ 402{
403 sample += error; 403 sample += error;
404 mad_fixed_t quantized = (sample >= MAD_F_ONE) ? MAD_F_ONE - 1 : ( (sample < -MAD_F_ONE) ? -MAD_F_ONE : sample ); 404 mad_fixed_t quantized = (sample >= MAD_F_ONE) ? MAD_F_ONE - 1 : ( (sample < -MAD_F_ONE) ? -MAD_F_ONE : sample );
405 quantized &= ~((1L << shift) - 1); 405 quantized &= ~((1L << shift) - 1);
406 error = sample - quantized; 406 error = sample - quantized;
407 return quantized >> shift; 407 return quantized >> shift;
408} 408}
409 409
410 410
411inline void audio_pcm( short *data, unsigned int nsamples, mad_fixed_t *left, mad_fixed_t *right ) 411inline void audio_pcm( short *data, unsigned int nsamples, mad_fixed_t *left, mad_fixed_t *right )
412{ 412{
413 if ( right ) { 413 if ( right ) {
414 while (nsamples--) { 414 while (nsamples--) {
415 data[0] = audio_linear_dither( *left++, left_err ); 415 data[0] = audio_linear_dither( *left++, left_err );
416 data[1] = audio_linear_dither( *right++, right_err ); 416 data[1] = audio_linear_dither( *right++, right_err );
417 data += 2; 417 data += 2;
418 } 418 }
419 } else { 419 } else {
420 while (nsamples--) { 420 while (nsamples--) {
421 data[0] = data[1] = audio_linear_dither( *left++, left_err ); 421 data[0] = data[1] = audio_linear_dither( *left++, left_err );
422 data += 2; 422 data += 2;
423 } 423 }
424 } 424 }
425} 425}
426 426
427 427
428bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) { 428bool LibMadPlugin::decode( short *output, long samples, long& samplesMade ) {
429 debugMsg( "LibMadPlugin::decode" ); 429 debugMsg( "LibMadPlugin::decode" );
430 430
431 static int buffered = 0; 431 static int buffered = 0;
432 static mad_fixed_t buffer[2][65536 * 2]; 432 static mad_fixed_t buffer[2][65536 * 2];
433 int offset = buffered; 433 int offset = buffered;
434 samplesMade = 0; 434 samplesMade = 0;
435 435
436 static int maxBuffered = 8000; // 65536; 436 static int maxBuffered = 8000; // 65536;
437 437
438 if ( samples > maxBuffered ) 438 if ( samples > maxBuffered )
439 samples = maxBuffered; 439 samples = maxBuffered;
440 440
441 if ( d->flush ) { 441 if ( d->flush ) {
442 buffered = 0; 442 buffered = 0;
443 offset = 0; 443 offset = 0;
444 d->flush = FALSE; 444 d->flush = FALSE;
445 } 445 }
446 446
447 while ( buffered < maxBuffered ) { 447 while ( buffered < maxBuffered ) {
448 448
449 while (mad_frame_decode(&d->frame, &d->stream) == -1) { 449 while (mad_frame_decode(&d->frame, &d->stream) == -1) {
450 if (!MAD_RECOVERABLE(d->stream.error)) { 450 if (!MAD_RECOVERABLE(d->stream.error)) {
451 debugMsg( "feed me" ); 451 debugMsg( "feed me" );
452 return FALSE; // Feed me 452 return FALSE; // Feed me
453 } 453 }
454 if ( d->stream.error == MAD_ERROR_BADCRC ) { 454 if ( d->stream.error == MAD_ERROR_BADCRC ) {
455 mad_frame_mute(&d->frame); 455 mad_frame_mute(&d->frame);
456 qDebug( "error decoding, bad crc" ); 456 qDebug( "error decoding, bad crc" );
457 } 457 }
458 } 458 }
459 459
460 mad_synth_frame(&d->synth, &d->frame); 460 mad_synth_frame(&d->synth, &d->frame);
461 int decodedSamples = d->synth.pcm.length; 461 int decodedSamples = d->synth.pcm.length;
462 memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) ); 462 memcpy( &(buffer[0][offset]), d->synth.pcm.samples[0], decodedSamples * sizeof(mad_fixed_t) );
463 if ( d->synth.pcm.channels == 2 ) 463 if ( d->synth.pcm.channels == 2 )
464 memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) ); 464 memcpy( &(buffer[1][offset]), d->synth.pcm.samples[1], decodedSamples * sizeof(mad_fixed_t) );
465 offset += decodedSamples; 465 offset += decodedSamples;
466 buffered += decodedSamples; 466 buffered += decodedSamples;
467 } 467 }
468 468
469 audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 ); 469 audio_pcm( output, samples, buffer[0], (d->synth.pcm.channels == 2) ? buffer[1] : 0 );
470// audio_pcm( output, samples, buffer[1], buffer[0] ); 470// audio_pcm( output, samples, buffer[1], buffer[0] );
471// audio_pcm( output, samples, buffer[0], buffer[1] ); 471// audio_pcm( output, samples, buffer[0], buffer[1] );
472 samplesMade = samples; 472 samplesMade = samples;
473 memmove( buffer[0], &(buffer[0][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); 473 memmove( buffer[0], &(buffer[0][samples]), (buffered - samples) * sizeof(mad_fixed_t) );
474 if ( d->synth.pcm.channels == 2 ) 474 if ( d->synth.pcm.channels == 2 )
475 memmove( buffer[1], &(buffer[1][samples]), (buffered - samples) * sizeof(mad_fixed_t) ); 475 memmove( buffer[1], &(buffer[1][samples]), (buffered - samples) * sizeof(mad_fixed_t) );
476 buffered -= samples; 476 buffered -= samples;
477 477
478 return TRUE; 478 return TRUE;
479} 479}
480 480
481/* 481/*
482bool LibMadPlugin::audioReadMonoSamples( short *, long, long&, int ) { 482bool LibMadPlugin::audioReadMonoSamples( short *, long, long&, int ) {
483 debugMsg( "LibMadPlugin::audioReadMonoSamples" ); 483 debugMsg( "LibMadPlugin::audioReadMonoSamples" );
484 return FALSE; 484 return FALSE;
485} 485}
486 486
487 487
488bool LibMadPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { 488bool LibMadPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) {
489*/ 489*/
490bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long samples, long& samplesMade, int ) { 490bool LibMadPlugin::audioReadSamples( short *output, int /*channels*/, long samples, long& samplesMade, int ) {
491 debugMsg( "LibMadPlugin::audioReadStereoSamples" ); 491 debugMsg( "LibMadPlugin::audioReadStereoSamples" );
492 492
493 static bool needInput = TRUE; 493 static bool needInput = TRUE;
494 494
495 if ( samples == 0 ) 495 if ( samples == 0 )
496 return TRUE; 496 return FALSE;
497 497
498 do { 498 do {
499 if ( needInput ) 499 if ( needInput )
500 if ( !read() ) { 500 if ( !read() ) {
501 // if ( d->input.eof ) 501 // if ( d->input.eof )
502 // needInput = FALSE; 502 // needInput = FALSE;
503 // else 503 // else
504 return TRUE; 504 return FALSE;
505 } 505 }
506 506
507 needInput = FALSE; 507 needInput = FALSE;
508 508
509 if ( decode( output, samples, samplesMade ) ) 509 if ( decode( output, samples, samplesMade ) )
510 return FALSE; 510 return TRUE;
511 else 511 else
512 needInput = TRUE; 512 needInput = TRUE;
513 } 513 }
514 while ( ( samplesMade < samples ) && ( !d->input.eof ) ); 514 while ( ( samplesMade < samples ) && ( !d->input.eof ) );
515/* 515/*
516 static bool firstTimeThru = TRUE; 516 static bool firstTimeThru = TRUE;
517 517
518 if ( firstTimeThru ) { 518 if ( firstTimeThru ) {
519 firstTimeThru = FALSE; 519 firstTimeThru = FALSE;
520 decode( output, samples, samplesMade ); 520 decode( output, samples, samplesMade );
521 return FALSE; 521 return FALSE;
522 } else 522 } else
523*/ 523*/
524 return TRUE; 524 return FALSE;
525} 525}
526 526
527 527
528double LibMadPlugin::getTime() { 528double LibMadPlugin::getTime() {
529 debugMsg( "LibMadPlugin::getTime" ); 529 debugMsg( "LibMadPlugin::getTime" );
530 return 0.0; 530 return 0.0;
531} 531}
532 532
533 533
534void LibMadPlugin::printID3Tags() { 534void LibMadPlugin::printID3Tags() {
535 debugMsg( "LibMadPlugin::printID3Tags" ); 535 debugMsg( "LibMadPlugin::printID3Tags" );
536 536
537 char id3v1[128 + 1]; 537 char id3v1[128 + 1];
538 538
539 if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) { 539 if ( ::lseek( d->input.fd, -128, SEEK_END ) == -1 ) {
540 qDebug( "error seeking to id3 tags" ); 540 qDebug( "error seeking to id3 tags" );
541 return; 541 return;
542 } 542 }
543 543
544 if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) { 544 if ( ::read( d->input.fd, id3v1, 128 ) != 128 ) {
545 qDebug( "error reading in id3 tags" ); 545 qDebug( "error reading in id3 tags" );
546 return; 546 return;
547 } 547 }
548 548
549 if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) { 549 if ( ::strncmp( (const char *)id3v1, "TAG", 3 ) != 0 ) {
550 debugMsg( "sorry, no id3 tags" ); 550 debugMsg( "sorry, no id3 tags" );
551 } else { 551 } else {
552 int len[5] = { 30, 30, 30, 4, 30 }; 552 int len[5] = { 30, 30, 30, 4, 30 };
553 QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) }; 553 QString label[5] = { tr( "Title" ), tr( "Artist" ), tr( "Album" ), tr( "Year" ), tr( "Comment" ) };
554 char *ptr = id3v1 + 3, *ptr2 = ptr + len[0]; 554 char *ptr = id3v1 + 3, *ptr2 = ptr + len[0];
555 qDebug( "ID3 tags in file:" ); 555 qDebug( "ID3 tags in file:" );
556 info = ""; 556 info = "";
557 for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) { 557 for ( int i = 0; i < 5; ptr += len[i], i++, ptr2 += len[i] ) {
558 char push = *ptr2; 558 char push = *ptr2;
559 *ptr2 = '\0'; 559 *ptr2 = '\0';
560 char *ptr3 = ptr2; 560 char *ptr3 = ptr2;
561 while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--; 561 while ( ptr3-1 >= ptr && isspace(ptr3[-1]) ) ptr3--;
562 char push2 = *ptr3; *ptr3 = '\0'; 562 char push2 = *ptr3; *ptr3 = '\0';
563 if ( strcmp( ptr, "" ) ) 563 if ( strcmp( ptr, "" ) )
564 info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr; 564 info += ( i != 0 ? ", " : "" ) + label[i] + ": " + ptr;
565 //qDebug( info.latin1() ); 565 //qDebug( info.latin1() );
566 *ptr3 = push2; 566 *ptr3 = push2;
567 *ptr2 = push; 567 *ptr2 = push;
568 } 568 }
569 if (id3v1[126] == 0 && id3v1[127] != 0) 569 if (id3v1[126] == 0 && id3v1[127] != 0)
570 info += tr( ", Track: " ) + id3v1[127]; 570 info += tr( ", Track: " ) + id3v1[127];
571 } 571 }
572 572
573 if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) { 573 if ( ::lseek(d->input.fd, 0, SEEK_SET) == -1 ) {
574 qDebug( "error seeking back to beginning" ); 574 qDebug( "error seeking back to beginning" );
575 return; 575 return;
576 } 576 }
577} 577}
578 578
diff --git a/core/multimedia/opieplayer/loopcontrol.cpp b/core/multimedia/opieplayer/loopcontrol.cpp
index 93a6e3f..6dfd057 100644
--- a/core/multimedia/opieplayer/loopcontrol.cpp
+++ b/core/multimedia/opieplayer/loopcontrol.cpp
@@ -135,208 +135,208 @@ void LoopControl::timerEvent( QTimerEvent *te ) {
135 if ( te->timerId() == sliderId ) { 135 if ( te->timerId() == sliderId ) {
136 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) { 136 if ( hasAudioChannel && !hasVideoChannel && moreAudio ) {
137 mediaPlayerState->updatePosition( audioSampleCounter ); 137 mediaPlayerState->updatePosition( audioSampleCounter );
138 } else if ( hasVideoChannel && moreVideo ) { 138 } else if ( hasVideoChannel && moreVideo ) {
139 mediaPlayerState->updatePosition( current_frame ); 139 mediaPlayerState->updatePosition( current_frame );
140 } 140 }
141 } 141 }
142 142
143 if ( !moreVideo && !moreAudio ) { 143 if ( !moreVideo && !moreAudio ) {
144 mediaPlayerState->setPlaying( FALSE ); 144 mediaPlayerState->setPlaying( FALSE );
145 mediaPlayerState->setNext(); 145 mediaPlayerState->setNext();
146 } 146 }
147} 147}
148 148
149 149
150void LoopControl::setPosition( long pos ) { 150void LoopControl::setPosition( long pos ) {
151 audioMutex->lock(); 151 audioMutex->lock();
152 152
153 if ( hasVideoChannel && hasAudioChannel ) { 153 if ( hasVideoChannel && hasAudioChannel ) {
154 playtime.restart(); 154 playtime.restart();
155 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 155 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
156 current_frame = pos + 1; 156 current_frame = pos + 1;
157 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 157 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
158 prev_frame = current_frame - 1; 158 prev_frame = current_frame - 1;
159 currentSample = (int)( (double)current_frame * freq / framerate ); 159 currentSample = (int)( (double)current_frame * freq / framerate );
160 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 160 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
161 audioSampleCounter = currentSample - 1; 161 audioSampleCounter = currentSample - 1;
162 } else if ( hasVideoChannel ) { 162 } else if ( hasVideoChannel ) {
163 playtime.restart(); 163 playtime.restart();
164 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) ); 164 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / framerate) );
165 current_frame = pos + 1; 165 current_frame = pos + 1;
166 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 166 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
167 prev_frame = current_frame - 1; 167 prev_frame = current_frame - 1;
168 } else if ( hasAudioChannel ) { 168 } else if ( hasAudioChannel ) {
169 playtime.restart(); 169 playtime.restart();
170 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) ); 170 playtime = playtime.addMSecs( long((double)-pos * 1000.0 / freq) );
171 currentSample = pos + 1; 171 currentSample = pos + 1;
172 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream ); 172 mediaPlayerState->curDecoder()->audioSetSample( currentSample, stream );
173 audioSampleCounter = currentSample - 1; 173 audioSampleCounter = currentSample - 1;
174 } 174 }
175 175
176 audioMutex->unlock(); 176 audioMutex->unlock();
177} 177}
178 178
179 179
180void LoopControl::startVideo() { 180void LoopControl::startVideo() {
181 181
182 if ( moreVideo ) { 182 if ( moreVideo ) {
183 183
184 if ( mediaPlayerState->curDecoder() ) { 184 if ( mediaPlayerState->curDecoder() ) {
185 185
186 if ( hasAudioChannel && !isMuted ) { 186 if ( hasAudioChannel && !isMuted ) {
187 187
188 current_frame = long( playtime.elapsed() * framerate / 1000 ); 188 current_frame = long( playtime.elapsed() * framerate / 1000 );
189 189
190 if ( prev_frame != -1 && current_frame <= prev_frame ) 190 if ( prev_frame != -1 && current_frame <= prev_frame )
191 return; 191 return;
192 192
193 } else { 193 } else {
194 // Don't skip 194 // Don't skip
195 current_frame++; 195 current_frame++;
196 } 196 }
197 197
198 if ( prev_frame == -1 || current_frame > prev_frame ) { 198 if ( prev_frame == -1 || current_frame > prev_frame ) {
199 if ( current_frame > prev_frame + 1 ) { 199 if ( current_frame > prev_frame + 1 ) {
200 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream ); 200 mediaPlayerState->curDecoder()->videoSetFrame( current_frame, stream );
201 } 201 }
202 moreVideo = videoUI->playVideo(); 202 moreVideo = videoUI->playVideo();
203 prev_frame = current_frame; 203 prev_frame = current_frame;
204 } 204 }
205 205
206 } else { 206 } else {
207 207
208 moreVideo = FALSE; 208 moreVideo = FALSE;
209 killTimer( videoId ); 209 killTimer( videoId );
210 210
211 } 211 }
212 212
213 } 213 }
214} 214}
215 215
216 216
217void LoopControl::startAudio() { 217void LoopControl::startAudio() {
218 218
219 audioMutex->lock(); 219 audioMutex->lock();
220 220
221 if ( moreAudio ) { 221 if ( moreAudio ) {
222 222
223 if ( !isMuted && mediaPlayerState->curDecoder() ) { 223 if ( !isMuted && mediaPlayerState->curDecoder() ) {
224 224
225 currentSample = audioSampleCounter + 1; 225 currentSample = audioSampleCounter + 1;
226 226
227 if ( currentSample != audioSampleCounter + 1 ) 227 if ( currentSample != audioSampleCounter + 1 )
228 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter); 228 qDebug("out of sync with decoder %i %i", currentSample, audioSampleCounter);
229 229
230 long samplesRead = 0; 230 long samplesRead = 0;
231 mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream ); 231 bool readOk=mediaPlayerState->curDecoder()->audioReadSamples( (short*)audioBuffer, channels, 1024, samplesRead, stream );
232 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000; 232 long sampleWeShouldBeAt = long( playtime.elapsed() ) * freq / 1000;
233 long sampleWaitTime = currentSample - sampleWeShouldBeAt; 233 long sampleWaitTime = currentSample - sampleWeShouldBeAt;
234 234
235 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) { 235 if ( ( sampleWaitTime > 2000 ) && ( sampleWaitTime < 20000 ) ) {
236 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) ); 236 usleep( (long)((double)sampleWaitTime * 1000000.0 / freq) );
237 } else if ( sampleWaitTime <= -5000 ) { 237 } else if ( sampleWaitTime <= -5000 ) {
238 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt ); 238 qDebug("need to catch up by: %li (%i,%li)", -sampleWaitTime, currentSample, sampleWeShouldBeAt );
239 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream ); 239 //mediaPlayerState->curDecoder()->audioSetSample( sampleWeShouldBeAt, stream );
240 currentSample = sampleWeShouldBeAt; 240 currentSample = sampleWeShouldBeAt;
241 } 241 }
242 242
243 audioDevice->write( audioBuffer, samplesRead * 2 * channels ); 243 audioDevice->write( audioBuffer, samplesRead * 2 * channels );
244 audioSampleCounter = currentSample + samplesRead - 1; 244 audioSampleCounter = currentSample + samplesRead - 1;
245 245
246 moreAudio = audioSampleCounter <= total_audio_samples; 246 moreAudio = readOk && (audioSampleCounter <= total_audio_samples);
247 247
248 } else { 248 } else {
249 249
250 moreAudio = FALSE; 250 moreAudio = FALSE;
251 251
252 } 252 }
253 253
254 } 254 }
255 255
256 audioMutex->unlock(); 256 audioMutex->unlock();
257} 257}
258 258
259 259
260void LoopControl::killTimers() { 260void LoopControl::killTimers() {
261 261
262 audioMutex->lock(); 262 audioMutex->lock();
263 263
264 if ( hasVideoChannel ) 264 if ( hasVideoChannel )
265 killTimer( videoId ); 265 killTimer( videoId );
266 killTimer( sliderId ); 266 killTimer( sliderId );
267 threadOkToGo = FALSE; 267 threadOkToGo = FALSE;
268 268
269 audioMutex->unlock(); 269 audioMutex->unlock();
270} 270}
271 271
272 272
273void LoopControl::startTimers() { 273void LoopControl::startTimers() {
274 274
275 audioMutex->lock(); 275 audioMutex->lock();
276 276
277 moreVideo = FALSE; 277 moreVideo = FALSE;
278 moreAudio = FALSE; 278 moreAudio = FALSE;
279 279
280 if ( hasVideoChannel ) { 280 if ( hasVideoChannel ) {
281 moreVideo = TRUE; 281 moreVideo = TRUE;
282 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value 282 int mSecsBetweenFrames = (int)(100 / framerate); // 10% of the real value
283 videoId = startTimer( mSecsBetweenFrames ); 283 videoId = startTimer( mSecsBetweenFrames );
284 } 284 }
285 285
286 if ( hasAudioChannel ) { 286 if ( hasAudioChannel ) {
287 moreAudio = TRUE; 287 moreAudio = TRUE;
288 threadOkToGo = TRUE; 288 threadOkToGo = TRUE;
289 } 289 }
290 290
291 sliderId = startTimer( 300 ); // update slider every 1/3 second 291 sliderId = startTimer( 300 ); // update slider every 1/3 second
292 292
293 audioMutex->unlock(); 293 audioMutex->unlock();
294} 294}
295 295
296 296
297void LoopControl::setPaused( bool pause ) { 297void LoopControl::setPaused( bool pause ) {
298 298
299 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() ) 299 if ( !mediaPlayerState->curDecoder() || !mediaPlayerState->curDecoder()->isOpen() )
300 return; 300 return;
301 301
302 if ( pause ) { 302 if ( pause ) {
303 killTimers(); 303 killTimers();
304 } else { 304 } else {
305 // Force an update of the position 305 // Force an update of the position
306 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 ); 306 mediaPlayerState->setPosition( mediaPlayerState->position() + 1 );
307 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 ); 307 mediaPlayerState->setPosition( mediaPlayerState->position() - 1 );
308 // Just like we never stopped 308 // Just like we never stopped
309 startTimers(); 309 startTimers();
310 } 310 }
311} 311}
312 312
313 313
314void LoopControl::stop( bool willPlayAgainShortly ) { 314void LoopControl::stop( bool willPlayAgainShortly ) {
315 315
316#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 316#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
317 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) { 317 if ( !willPlayAgainShortly && disabledSuspendScreenSaver ) {
318 disabledSuspendScreenSaver = FALSE; 318 disabledSuspendScreenSaver = FALSE;
319 // Re-enable the suspend mode 319 // Re-enable the suspend mode
320 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; 320 QCopEnvelope("QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable;
321 } 321 }
322#endif 322#endif
323 323
324 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) { 324 if ( mediaPlayerState->curDecoder() && mediaPlayerState->curDecoder()->isOpen() ) {
325 325
326 killTimers(); 326 killTimers();
327 327
328 audioMutex->lock(); 328 audioMutex->lock();
329 329
330 mediaPlayerState->curDecoder()->close(); 330 mediaPlayerState->curDecoder()->close();
331 331
332 if ( audioDevice ) { 332 if ( audioDevice ) {
333 delete audioDevice; 333 delete audioDevice;
334 delete audioBuffer; 334 delete audioBuffer;
335 audioDevice = 0; 335 audioDevice = 0;
336 audioBuffer = 0; 336 audioBuffer = 0;
337 } 337 }
338 338
339 audioMutex->unlock(); 339 audioMutex->unlock();
340 340
341 } 341 }
342} 342}
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
index 60a0024..a6bd974 100644
--- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
+++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
@@ -230,105 +230,105 @@ bool WavPlugin::open( const QString& path ) {
230 d->wavedata_remaining = 0; 230 d->wavedata_remaining = 0;
231 d->samples_due = 0; 231 d->samples_due = 0;
232 232
233 d->input = new QFile( path ); 233 d->input = new QFile( path );
234 if ( d->input->open(IO_ReadOnly) == FALSE ) { 234 if ( d->input->open(IO_ReadOnly) == FALSE ) {
235 qDebug("couldn't open file"); 235 qDebug("couldn't open file");
236 delete d->input; 236 delete d->input;
237 d->input = 0; 237 d->input = 0;
238 return FALSE; 238 return FALSE;
239 } 239 }
240 240
241 d->initialise(); 241 d->initialise();
242 242
243 return TRUE; 243 return TRUE;
244} 244}
245 245
246 246
247bool WavPlugin::close() { 247bool WavPlugin::close() {
248 debugMsg( "WavPlugin::close" ); 248 debugMsg( "WavPlugin::close" );
249 249
250 d->input->close(); 250 d->input->close();
251 delete d->input; 251 delete d->input;
252 d->input = 0; 252 d->input = 0;
253 return TRUE; 253 return TRUE;
254} 254}
255 255
256 256
257bool WavPlugin::isOpen() { 257bool WavPlugin::isOpen() {
258 debugMsg( "WavPlugin::isOpen" ); 258 debugMsg( "WavPlugin::isOpen" );
259 return ( d->input != 0 ); 259 return ( d->input != 0 );
260} 260}
261 261
262 262
263int WavPlugin::audioStreams() { 263int WavPlugin::audioStreams() {
264 debugMsg( "WavPlugin::audioStreams" ); 264 debugMsg( "WavPlugin::audioStreams" );
265 return 1; 265 return 1;
266} 266}
267 267
268 268
269int WavPlugin::audioChannels( int ) { 269int WavPlugin::audioChannels( int ) {
270 debugMsg( "WavPlugin::audioChannels" ); 270 debugMsg( "WavPlugin::audioChannels" );
271 return 2; // ### Always scale audio to stereo samples 271 return 2; // ### Always scale audio to stereo samples
272} 272}
273 273
274 274
275int WavPlugin::audioFrequency( int ) { 275int WavPlugin::audioFrequency( int ) {
276 debugMsg( "WavPlugin::audioFrequency" ); 276 debugMsg( "WavPlugin::audioFrequency" );
277 return 44100; // ### Always scale to frequency of 44100 277 return 44100; // ### Always scale to frequency of 44100
278} 278}
279 279
280 280
281int WavPlugin::audioSamples( int ) { 281int WavPlugin::audioSamples( int ) {
282 debugMsg( "WavPlugin::audioSamples" ); 282 debugMsg( "WavPlugin::audioSamples" );
283 return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo, 283 return d->samples * 2 / d->chunkdata.channels; // ### Scaled samples will be made stereo,
284 // Therefore if source is mono we will double the number of samples 284 // Therefore if source is mono we will double the number of samples
285} 285}
286 286
287 287
288bool WavPlugin::audioSetSample( long, int ) { 288bool WavPlugin::audioSetSample( long, int ) {
289 debugMsg( "WavPlugin::audioSetSample" ); 289 debugMsg( "WavPlugin::audioSetSample" );
290 return FALSE; 290 return FALSE;
291} 291}
292 292
293 293
294long WavPlugin::audioGetSample( int ) { 294long WavPlugin::audioGetSample( int ) {
295 debugMsg( "WavPlugin::audioGetSample" ); 295 debugMsg( "WavPlugin::audioGetSample" );
296 return 0; 296 return 0;
297} 297}
298 298
299/* 299/*
300bool WavPlugin::audioReadSamples( short *, int, long, int ) { 300bool WavPlugin::audioReadSamples( short *, int, long, int ) {
301 debugMsg( "WavPlugin::audioReadSamples" ); 301 debugMsg( "WavPlugin::audioReadSamples" );
302 return FALSE; 302 return FALSE;
303} 303}
304 304
305 305
306bool WavPlugin::audioReReadSamples( short *, int, long, int ) { 306bool WavPlugin::audioReReadSamples( short *, int, long, int ) {
307 debugMsg( "WavPlugin::audioReReadSamples" ); 307 debugMsg( "WavPlugin::audioReReadSamples" );
308 return FALSE; 308 return FALSE;
309} 309}
310 310
311 311
312bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) { 312bool WavPlugin::audioReadMonoSamples( short *output, long samples, long& samplesMade, int ) {
313 debugMsg( "WavPlugin::audioReadMonoSamples" ); 313 debugMsg( "WavPlugin::audioReadMonoSamples" );
314 return !d->add( output, samples, samplesMade, FALSE ); 314 return !d->add( output, samples, samplesMade, FALSE );
315} 315}
316 316
317 317
318bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) { 318bool WavPlugin::audioReadStereoSamples( short *output, long samples, long& samplesMade, int ) {
319 debugMsg( "WavPlugin::audioReadStereoSamples" ); 319 debugMsg( "WavPlugin::audioReadStereoSamples" );
320 return !d->add( output, samples, samplesMade, TRUE ); 320 return !d->add( output, samples, samplesMade, TRUE );
321} 321}
322*/ 322*/
323 323
324bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) { 324bool WavPlugin::audioReadSamples( short *output, int channels, long samples, long& samplesMade, int ) {
325 debugMsg( "WavPlugin::audioReadSamples" ); 325 debugMsg( "WavPlugin::audioReadSamples" );
326 return !d->add( output, samples, samplesMade, channels != 1 ); 326 return d->add( output, samples, samplesMade, channels != 1 );
327} 327}
328 328
329double WavPlugin::getTime() { 329double WavPlugin::getTime() {
330 debugMsg( "WavPlugin::getTime" ); 330 debugMsg( "WavPlugin::getTime" );
331 return 0.0; 331 return 0.0;
332} 332}
333 333
334 334