Commit c25fe30a authored by David Reid's avatar David Reid

WASAPI: Handle AUDCLNT_E_BUFFER_ERROR when processing audio data.

Public issue https://github.com/mackron/miniaudio/issues/410
parent cb2e3a7c
...@@ -21964,7 +21964,7 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui ...@@ -21964,7 +21964,7 @@ static ma_result ma_device_read__wasapi(ma_device* pDevice, void* pFrames, ma_ui
continue; continue;
} else { } 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 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 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 ...@@ -22078,7 +22078,7 @@ static ma_result ma_device_write__wasapi(ma_device* pDevice, const void* pFrames
pDevice->wasapi.mappedBufferPlaybackCap = bufferSizeInFrames; pDevice->wasapi.mappedBufferPlaybackCap = bufferSizeInFrames;
pDevice->wasapi.mappedBufferPlaybackLen = 0; pDevice->wasapi.mappedBufferPlaybackLen = 0;
} else { } 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. */ /* Not enough data available. We need to wait for more. */
if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) { if (WaitForSingleObject(pDevice->wasapi.hEventPlayback, MA_WASAPI_WAIT_TIMEOUT_MILLISECONDS) != WAIT_OBJECT_0) {
break; /* Wait failed. Probably timed out. */ break; /* Wait failed. Probably timed out. */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment