From c7e07df5151904d8ef244fd0566c14a4e259d06d Mon Sep 17 00:00:00 2001 From: zgaetano Date: Mon, 1 Jun 2026 07:51:10 -0400 Subject: [PATCH] fix(capture): handle partial writes in audio_thread FIFO write loop --- services/capture/deltacast-bridge/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/services/capture/deltacast-bridge/main.c b/services/capture/deltacast-bridge/main.c index 91635d0..d38e3e2 100644 --- a/services/capture/deltacast-bridge/main.c +++ b/services/capture/deltacast-bridge/main.c @@ -141,7 +141,14 @@ static void *audio_thread(void *arg) { ai.pAudioGroups[0].pAudioChannels[0].DataSize = buf_sz; if (VHD_SlotExtractAudio(slot, &ai) == VHDERR_NOERROR) { ULONG sz = ai.pAudioGroups[0].pAudioChannels[0].DataSize; - if (sz > 0) write(fd, buf, sz); + if (sz > 0) { + ULONG aw = 0; + while (aw < sz) { + ssize_t n = write(fd, buf + aw, sz - aw); + if (n <= 0) { atomic_store(&g_stop, 1); break; } + aw += (ULONG)n; + } + } } VHD_UnlockSlotHandle(slot); } else if (r != VHDERR_TIMEOUT) {