audio/sdlaudio: Simplify the sdl_callback function

At the end of the while-loop, either "samples" or "sdl->live" is zero, so
now that we've removed the semaphore code, the content of the while-loop
is always only executed once. Thus we can remove the while-loop now to
get rid of one indentation level here.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-id: 1549336101-17623-3-git-send-email-thuth@redhat.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
This commit is contained in:
Thomas Huth 2019-02-05 04:08:21 +01:00 committed by Gerd Hoffmann
parent 8a7816c4ac
commit 9399ef1683
1 changed files with 17 additions and 24 deletions

View File

@ -189,21 +189,14 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
SDLAudioState *s = &glob_sdl; SDLAudioState *s = &glob_sdl;
HWVoiceOut *hw = &sdl->hw; HWVoiceOut *hw = &sdl->hw;
int samples = len >> hw->info.shift; int samples = len >> hw->info.shift;
int to_mix, decr;
if (s->exit) { if (s->exit || !sdl->live) {
return; return;
} }
while (samples) { /* dolog ("in callback samples=%d live=%d\n", samples, sdl->live); */
int to_mix, decr;
/* dolog ("in callback samples=%d\n", samples); */
if (s->exit || !sdl->live) {
break;
}
/* dolog ("in callback live=%d\n", live); */
to_mix = audio_MIN(samples, sdl->live); to_mix = audio_MIN(samples, sdl->live);
decr = to_mix; decr = to_mix;
while (to_mix) { while (to_mix) {
@ -219,7 +212,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
samples -= decr; samples -= decr;
sdl->live -= decr; sdl->live -= decr;
sdl->decr += decr; sdl->decr += decr;
}
/* dolog ("done len=%d\n", len); */ /* dolog ("done len=%d\n", len); */
/* SDL2 does not clear the remaining buffer for us, so do it on our own */ /* SDL2 does not clear the remaining buffer for us, so do it on our own */