From c25fe30aa6a0e9e1d3ee8ca596329eb02ea789a9 Mon Sep 17 00:00:00 2001 From: David Reid Date: Tue, 18 Jan 2022 17:36:26 +1000 Subject: [PATCH] WASAPI: Handle AUDCLNT_E_BUFFER_ERROR when processing audio data. Public issue https://github.com/mackron/miniaudio/issues/410 --- miniaudio.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index 67ac4c07..c650db75 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -21964,7 +21964,7 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui continue; } else { - if (hr == MA_AUDCLNT_S_BUFFER_EMPTY) { + if (hr == MA_AUDCLNT_S_BUFFER_EMPTY || hr == MA_AUDCLNT_E_BUFFER_ERROR) { /* No data is available. We need to wait for more. There's two situations to consider here. The first is normal capture mode. If this times out it probably means the @@ -22078,7 +22078,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames pDevice->wasapi.mappedBufferPlaybackCap = bufferSizeInFrames; pDevice->wasapi.mappedBufferPlaybackLen = 0; } else { - if (hr == MA_AUDCLNT_E_BUFFER_TOO_LARGE) { + if (hr == MA_AUDCLNT_E_BUFFER_TOO_LARGE || hr == MA_AUDCLNT_E_BUFFER_ERROR) { /* Not enough data available. We need to wait for more. */ if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) { break; /* Wait failed. Probably timed out. */