Commit 9399ef16 authored by Thomas Huth's avatar Thomas Huth Committed by Gerd Hoffmann
Browse files

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: default avatarThomas Huth <thuth@redhat.com>
Message-id: 1549336101-17623-3-git-send-email-thuth@redhat.com
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 8a7816c4
Loading
Loading
Loading
Loading
+19 −26
Original line number Diff line number Diff line
@@ -189,21 +189,14 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
    SDLAudioState *s = &glob_sdl;
    HWVoiceOut *hw = &sdl->hw;
    int samples = len >> hw->info.shift;

    if (s->exit) {
        return;
    }

    while (samples) {
    int to_mix, decr;

        /* dolog ("in callback samples=%d\n", samples); */

    if (s->exit || !sdl->live) {
            break;
        return;
    }

        /* dolog ("in callback live=%d\n", live); */
    /* dolog ("in callback samples=%d live=%d\n", samples, sdl->live); */

    to_mix = audio_MIN(samples, sdl->live);
    decr = to_mix;
    while (to_mix) {
@@ -219,7 +212,7 @@ static void sdl_callback (void *opaque, Uint8 *buf, int len)
    samples -= decr;
    sdl->live -= decr;
    sdl->decr += decr;
    }

    /* dolog ("done len=%d\n", len); */

    /* SDL2 does not clear the remaining buffer for us, so do it on our own */