[Commits] SDL: wasapi: Deal with AUDCLNT_S_BUFFER_EMPTY when flushing audi...

libsdl.org revision control commits-owner at libsdl.org
Thu May 18 12:43:57 PDT 2017


details:   https://hg.libsdl.org/SDL/rev/cca512965b67
changeset: 11009:cca512965b67
user:      Ryan C. Gordon <icculus at icculus.org>
date:      Thu May 18 15:43:51 2017 -0400
description:
wasapi: Deal with AUDCLNT_S_BUFFER_EMPTY when flushing audio device.

diffstat:

 src/audio/wasapi/SDL_wasapi.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (21 lines):

diff -r c923c6eac264 -r cca512965b67 src/audio/wasapi/SDL_wasapi.c
--- a/src/audio/wasapi/SDL_wasapi.c	Thu May 18 15:33:17 2017 -0400
+++ b/src/audio/wasapi/SDL_wasapi.c	Thu May 18 15:43:51 2017 -0400
@@ -609,9 +609,14 @@
         DWORD flags = 0;
 
         /* just read until we stop getting packets, throwing them away. */
-        while (!WasapiFailed(this, IAudioCaptureClient_GetBuffer(this->hidden->capture, &ptr, &frames, &flags, NULL, NULL))) {
-            if (WasapiFailed(this, IAudioCaptureClient_ReleaseBuffer(this->hidden->capture, frames))) {
-                break;
+        while (SDL_TRUE) {
+            const HRESULT ret = IAudioCaptureClient_GetBuffer(this->hidden->capture, &ptr, &frames, &flags, NULL, NULL));
+            if (ret == AUDCLNT_S_BUFFER_EMPTY) {
+                break;  /* no more buffered data; we're done. */
+            } else if (WasapiFailed(this, ret)) {
+                break;  /* failed for some other reason, abort. */
+            } else if (WasapiFailed(this, IAudioCaptureClient_ReleaseBuffer(this->hidden->capture, frames))) {
+                break;  /* something broke. */
             }
         }
         SDL_AudioStreamClear(this->hidden->capturestream);


More information about the commits mailing list