From 9c6876ac18fd9436a6849845ba7b5be8ccb31e34 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Thu, 2 Apr 2026 11:48:35 -0400
Subject: [PATCH] pipewire: Don't mark a device disconnected if
pw_stream_dequeue_buffer fails.
Apparently this _can_ happen under load, or maybe some other weird condition.
Hopefully this will encourage PipeWire to fire output_callback again, and
we'll just try again later.
Reference Issue #14916.
(cherry picked from commit 32ef82caaf29ec340ac4614859668f734279fd66)
---
src/audio/pipewire/SDL_pipewire.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/audio/pipewire/SDL_pipewire.c b/src/audio/pipewire/SDL_pipewire.c
index ee59ca391fc3c..b3882753e5928 100644
--- a/src/audio/pipewire/SDL_pipewire.c
+++ b/src/audio/pipewire/SDL_pipewire.c
@@ -934,18 +934,18 @@ static void initialize_spa_info(const SDL_AudioSpec *spec, struct spa_audio_info
static Uint8 *PIPEWIRE_GetDeviceBuf(SDL_AudioDevice *device, int *buffer_size)
{
- // See if a buffer is available. If this returns NULL, SDL_PlaybackAudioThreadIterate will return false, but since we own the thread, it won't kill playback.
- // !!! FIXME: It's not clear to me if this ever returns NULL or if this was just defensive coding.
-
+ // See if a buffer is available. If this sets *buffer_size=0, then SDL_PlaybackAudioThreadIterate will skip this iteration but try again next time.
struct pw_stream *stream = device->hidden->stream;
struct pw_buffer *pw_buf = PIPEWIRE_pw_stream_dequeue_buffer(stream);
if (pw_buf == NULL) {
+ *buffer_size = 0;
return NULL;
}
struct spa_buffer *spa_buf = pw_buf->buffer;
if (spa_buf->datas[0].data == NULL) {
PIPEWIRE_pw_stream_queue_buffer(stream, pw_buf);
+ *buffer_size = 0;
return NULL;
}