From 9d294f1fca2bfb46c94e77aed0b6fa3bb1368c7a Mon Sep 17 00:00:00 2001 From: Ethan Lee Date: Sat, 27 Mar 2021 00:53:10 -0400 Subject: [PATCH] audio: Allow AudioStreamGet to return 0 in RunAudio. While we should normally expect _something_ from the stream based on the AudioStreamAvailable check, it's possible for a device change to flush the stream at an inconvenient time, causing this function to return 0. Thing is, this is harmless. Either data will be NULL and the result won't matter anyway, or the data buffer will be zeroed out and the output will just be silence for the brief moment that the device change is occurring. Both scenarios work themselves out, and testing on Windows shows that this behavior is safe. --- src/audio/SDL_audio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 00ee976c6..d25cd629d 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -759,7 +759,7 @@ SDL_RunAudio(void *devicep) int got; data = SDL_AtomicGet(&device->enabled) ? current_audio.impl.GetDeviceBuf(device) : NULL; got = SDL_AudioStreamGet(device->stream, data ? data : device->work_buffer, device->spec.size); - SDL_assert((got < 0) || (got == device->spec.size)); + SDL_assert((got <= 0) || (got == device->spec.size)); if (data == NULL) { /* device is having issues... */ const Uint32 delay = ((device->spec.samples * 1000) / device->spec.freq);