SDL: pulseaudio: Just feed the device whenever it asks for any amount of data.

From 61e9a9dd560497634c516a7b6c379e741a49d009 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Fri, 29 Sep 2023 22:34:11 -0400
Subject: [PATCH] pulseaudio: Just feed the device whenever it asks for any
 amount of data.

In practice, this seems to buffer a little upfront and then gives a pretty
consistent request flow after that of 1/4 of the requested buffer size without
variation, which is significantly better than the previous code that would
vary a little each frame.

Plus, as long as the device asks for _anything_, we won't block forever, and
if it asks for more than our expected buffer size, we'll run multiple times
to satisfy it, so this is likely more robust against dropouts in general, too.
---
 src/audio/pulseaudio/SDL_pulseaudio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c
index 4afde0788e3e..d8246460104b 100644
--- a/src/audio/pulseaudio/SDL_pulseaudio.c
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c
@@ -402,7 +402,7 @@ static void PULSEAUDIO_WaitDevice(SDL_AudioDevice *device)
 
     PULSEAUDIO_pa_threaded_mainloop_lock(pulseaudio_threaded_mainloop);
 
-    while (!SDL_AtomicGet(&device->shutdown) && (h->bytes_requested < (device->buffer_size / 4))) {
+    while (!SDL_AtomicGet(&device->shutdown) && (h->bytes_requested == 0)) {
         /*printf("PULSEAUDIO WAIT IN WAITDEVICE!\n");*/
         PULSEAUDIO_pa_threaded_mainloop_wait(pulseaudio_threaded_mainloop);