fix(capture): handle partial writes in audio_thread FIFO write loop

This commit is contained in:
Zac Gaetano 2026-06-01 07:51:10 -04:00
parent 67c071a0ee
commit c7e07df515

View file

@ -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) {