From 65b1a7dc3bb921a40205a02b944208ef5179babe Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 5 May 2024 10:04:58 -0400 Subject: [PATCH] sdl2: Fix broken audio in MVE playback. This doesn't fix the audio gaps, just the static introduced in the SDL2 port. SDL2 does not initialize the audio callback's buffer, unlike SDL 1.2, under the assumption the callback is going to fully write it anyhow. But since the movie player wants to mix against the current contents of the buffer, we need to explicitly initialize it to silence first. --- libmve/lnxdsound.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libmve/lnxdsound.cpp b/libmve/lnxdsound.cpp index 5787e35f..e4ab4622 100644 --- a/libmve/lnxdsound.cpp +++ b/libmve/lnxdsound.cpp @@ -775,6 +775,8 @@ static void LinuxSoundMixBuffersIntoMain(int len) { } static void LinuxSoundThreadHandler(void *unused, Uint8 *stream, int len) { + SDL_memset(stream, '\0', len); + LnxBuffers[0]->buffer = stream; LnxBuffers[0]->buffer_len = len; LnxBuffers[0]->play_cursor = 0;