comparison src/audio/SDL_audio.c @ 3096:ae4e80dbe330

Date: Tue, 17 Feb 2009 14:00:25 +0100 From: Stefan Klug Subject: [SDL] Possible bug, paused audio playing garbage On my WinCE device a paused audio device plays random garbage. This might also be the issue in the thread "sound cracks with SDL_mixer and AUDIO_S16LSB" I don't have that much knowledge of the SDL audio part, but the attached patch fixes it for me, and collapses two redundant ifs. I'm not sure if this is the correct way to fix this. Shouldn't the complete stream conversion part of the RunAudio loop be dependent on the paused property of the device? (not only the call to (*fill)(udata, istream, istream_len). Anyways. Would be great if the patch or a fix could find its way to SVN ;-) Cheers Stefan
author Sam Lantinga <slouken@libsdl.org>
date Mon, 23 Mar 2009 05:21:40 +0000
parents 62d4992e5a92
children 82e60908fab1
comparison
equal deleted inserted replaced
3095:75483112b97f 3096:ae4e80dbe330
470 470
471 /* Now read from the streamer */ 471 /* Now read from the streamer */
472 SDL_StreamRead(&device->streamer, stream, stream_len); 472 SDL_StreamRead(&device->streamer, stream, stream_len);
473 473
474 /* Ready current buffer for play and change current buffer */ 474 /* Ready current buffer for play and change current buffer */
475 if (stream != device->fake_stream) { 475 if (stream != device->fake_stream && !device->paused) {
476 current_audio.impl.PlayDevice(device); 476 current_audio.impl.PlayDevice(device);
477 } 477 /* Wait for an audio buffer to become available */
478 478 current_audio.impl.WaitDevice(device);
479 /* Wait for an audio buffer to become available */
480 if (stream == device->fake_stream) {
481 SDL_Delay((device->spec.samples * 1000) /
482 device->spec.freq);
483 } else { 479 } else {
484 current_audio.impl.WaitDevice(device); 480 SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
485 } 481 }
486 } 482 }
487 483
488 } 484 }
489 } else { 485 } else {
522 SDL_memcpy(stream, device->convert.buf, 518 SDL_memcpy(stream, device->convert.buf,
523 device->convert.len_cvt); 519 device->convert.len_cvt);
524 } 520 }
525 521
526 /* Ready current buffer for play and change current buffer */ 522 /* Ready current buffer for play and change current buffer */
527 if (stream != device->fake_stream) { 523 if (stream != device->fake_stream && !device->paused) {
528 current_audio.impl.PlayDevice(device); 524 current_audio.impl.PlayDevice(device);
529 } 525 /* Wait for an audio buffer to become available */
530 526 current_audio.impl.WaitDevice(device);
531 /* Wait for an audio buffer to become available */
532 if (stream == device->fake_stream) {
533 SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
534 } else { 527 } else {
535 current_audio.impl.WaitDevice(device); 528 SDL_Delay((device->spec.samples * 1000) / device->spec.freq);
536 } 529 }
537 } 530 }
538 } 531 }
539 532
540 /* Wait for the audio to drain.. */ 533 /* Wait for the audio to drain.. */