From 5efc22ab478b0edc57d96c8132415d5b9eca37b6 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Mon, 23 Mar 2009 05:21:40 +0000 Subject: [PATCH] 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 --- src/audio/SDL_audio.c | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 20602a6a2..35326669c 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -472,16 +472,12 @@ SDL_RunAudio(void *devicep) SDL_StreamRead(&device->streamer, stream, stream_len); /* Ready current buffer for play and change current buffer */ - if (stream != device->fake_stream) { + if (stream != device->fake_stream && !device->paused) { current_audio.impl.PlayDevice(device); - } - - /* Wait for an audio buffer to become available */ - if (stream == device->fake_stream) { - SDL_Delay((device->spec.samples * 1000) / - device->spec.freq); - } else { + /* Wait for an audio buffer to become available */ current_audio.impl.WaitDevice(device); + } else { + SDL_Delay((device->spec.samples * 1000) / device->spec.freq); } } @@ -524,15 +520,12 @@ SDL_RunAudio(void *devicep) } /* Ready current buffer for play and change current buffer */ - if (stream != device->fake_stream) { + if (stream != device->fake_stream && !device->paused) { current_audio.impl.PlayDevice(device); - } - - /* Wait for an audio buffer to become available */ - if (stream == device->fake_stream) { - SDL_Delay((device->spec.samples * 1000) / device->spec.freq); - } else { + /* Wait for an audio buffer to become available */ current_audio.impl.WaitDevice(device); + } else { + SDL_Delay((device->spec.samples * 1000) / device->spec.freq); } } }