Commit d713a68071fe3ad8a60be3d92054a04325c5dfd8

Ryan C. Gordon 2021-11-25T22:32:40

pulseaudio: wait until at least 1/8th (!) of the mixbuffer is available. This is to workaround systems where we hang in playback because the buffer does not report the space for whatever reason. The system will instead block in PlayDevice, which always immediately follows WaitDevice in modern times so this works out, and it seems to keep the device moving forward. For a future revision, we are either going to clean this up more properly, or attempt to move to PulseAudio's pa_stream_set_write_callback() API, but this will do for SDL 2.0.18. Reference #4387 for discussion and further information.

1
2
3
4
5
6
7
8
9
10
11
12
13
diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c
index 4a1823d..a7e181c 100644
--- a/src/audio/pulseaudio/SDL_pulseaudio.c
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c
@@ -368,7 +368,7 @@ PULSEAUDIO_WaitDevice(_THIS)
             SDL_OpenedAudioDeviceDisconnected(this);
             return;
         }
-        if (PULSEAUDIO_pa_stream_writable_size(h->stream) >= h->mixlen) {
+        if (PULSEAUDIO_pa_stream_writable_size(h->stream) >= (h->mixlen/8)) {
             return;
         }
     }