From 43bf6a1a97d6ac18dfa9dbeea86bb94b5f713bdd Mon Sep 17 00:00:00 2001 From: David Reid Date: Mon, 30 Sep 2019 20:27:20 +1000 Subject: [PATCH] WASAPI: Properly detect and report overruns in duplex mode. --- miniaudio.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/miniaudio.h b/miniaudio.h index d68c2f3c..ed8d724f 100644 --- a/miniaudio.h +++ b/miniaudio.h @@ -9158,19 +9158,19 @@ ma_result ma_device_main_loop__wasapi(ma_device* pDevice) break; } - /* - Debug output for IAudioCaptureClient_GetBuffer(). The flagsCapture variable will contain information. A glitch will occur when - AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY (1) is set. - */ - #ifdef MA_DEBUG_OUTPUT - if (flagsCapture != 0) { - printf("[WASAPI] Capture Flags: %d\n", flagsCapture); - } - #endif + /* Overrun detection. */ if ((flagsCapture & MA_AUDCLNT_BUFFERFLAGS_DATA_DISCONTINUITY) == 0) { /* Glitched. Probably due to an overrun. */ - + #ifdef MA_DEBUG_OUTPUT + printf("[WASAPI] Overrun.\n"); + #endif + } else { + #ifdef MA_DEBUG_OUTPUT + if (flagsCapture != 0) { + printf("[WASAPI] Capture Flags: %d\n", flagsCapture); + } + #endif } mappedBufferFramesRemainingCapture = mappedBufferSizeInFramesCapture;