Skip to content

Commit

Permalink
audio: Initialize the audio callback buffer with silence
Browse files Browse the repository at this point in the history
Some apps (DeSmuME) won't necessarily write to it like they're
supposed to, so we will end up playing uninitialized memory.
  • Loading branch information
cgutman authored and slouken committed Feb 23, 2025
1 parent f466e90 commit 943ad54
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/sdl2_compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -6842,6 +6842,9 @@ static SDL_AudioDeviceID OpenAudioDeviceLocked(const char *devicename, int iscap
return 0;
}

/* Some apps may leave the callback buffer unmodified, so initialize it with silence */
SDL3_memset(stream2->callback2_buffer, obtained2->silence, stream2->bytes_per_callbacks);

stream2->callback2 = desired2->callback;
stream2->callback2_userdata = desired2->userdata;
if (iscapture) {
Expand Down

0 comments on commit 943ad54

Please sign in to comment.