From e6995ecad763822728cc89f8a6338cfa753a07f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Fri, 8 May 2015 16:35:38 +0200 Subject: [PATCH] sdl: sync tail pointer in SDL_Audio backend SDL uses the Audio_out session in streaming fashion. For this reason the audio might be played with delay of at most the queue size. To mitigate the effect we synchronize the tail pointer to the current play pointer when the PlayAudio() function is called by SDL for the first time. Fixes #1612. --- repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc index 276055e265..b0ad2d0ff8 100644 --- a/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc +++ b/repos/libports/src/lib/sdl/audio/SDL_genodeaudio.cc @@ -186,6 +186,18 @@ static void GENODEAUD_WaitAudio(_THIS) static void GENODEAUD_PlayAudio(_THIS) { + /* + * Synchronize the play pointer when this function is first called + */ + static bool initial_reset = true; + if (initial_reset) { + for (int channel = 0; channel < AUDIO_CHANNELS; channel++) { + Audio_out::Connection *connection = _this->hidden->audio[channel]; + connection->stream()->reset(); + } + initial_reset = false; + } + Audio_out::Packet *p[AUDIO_CHANNELS]; for (int channel = 0; channel < AUDIO_CHANNELS; channel++)