sdl2: Zero out buffer on sound callback

This commit is contained in:
Ronald Kinard 2014-03-20 20:07:12 -05:00
parent 40de8ea630
commit 3839c2fd58

View file

@ -856,6 +856,7 @@ FUNCINLINE static ATTRINLINE void I_UpdateStream16S(Uint8 *stream, int len)
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
// Mix sounds into the mixing buffer. // Mix sounds into the mixing buffer.
// Loop over len // Loop over len
while (len--) while (len--)
@ -945,6 +946,7 @@ FUNCINLINE static ATTRINLINE void I_UpdateStream16M(Uint8 *stream, int len)
if (Snd_Mutex) SDL_LockMutex(Snd_Mutex); if (Snd_Mutex) SDL_LockMutex(Snd_Mutex);
// Mix sounds into the mixing buffer. // Mix sounds into the mixing buffer.
// Loop over len // Loop over len
while (len--) while (len--)
@ -1050,10 +1052,7 @@ static void SDLCALL I_UpdateStream(void *userdata, Uint8 *stream, int len)
if (!sound_started || !userdata) if (!sound_started || !userdata)
return; return;
#if SDL_VERSION_ATLEAST(1,3,0) memset(stream, 0x00, len); // only work in !AUDIO_U8, that needs 0x80
if (musicStarted)
memset(stream, 0x00, len); // only work in !AUDIO_U8, that needs 0x80
#endif
if ((audio.channels != 1 && audio.channels != 2) || if ((audio.channels != 1 && audio.channels != 2) ||
(audio.format != AUDIO_S8 && audio.format != AUDIO_S16SYS)) (audio.format != AUDIO_S8 && audio.format != AUDIO_S16SYS))