From 4a734209a3512abe6ca54fbe91e0b700061ca09d Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Thu, 27 Jul 2017 22:52:19 -0700 Subject: [PATCH] Fixed infinite recursion if the WASAPI audio device couldn't be recovered --- src/audio/wasapi/SDL_wasapi.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/audio/wasapi/SDL_wasapi.c b/src/audio/wasapi/SDL_wasapi.c index 461904ae99f73..6af22ceb06e4a 100644 --- a/src/audio/wasapi/SDL_wasapi.c +++ b/src/audio/wasapi/SDL_wasapi.c @@ -605,24 +605,22 @@ WASAPI_CaptureFromDevice(_THIS, void *buffer, int buflen) static void WASAPI_FlushCapture(_THIS) { - if (RecoverWasapiIfLost(this)) { - BYTE *ptr = NULL; - UINT32 frames = 0; - DWORD flags = 0; - - /* just read until we stop getting packets, throwing them away. */ - 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. */ - } + BYTE *ptr = NULL; + UINT32 frames = 0; + DWORD flags = 0; + + /* just read until we stop getting packets, throwing them away. */ + 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); } + SDL_AudioStreamClear(this->hidden->capturestream); } static void