Fixed infinite recursion if the WASAPI audio device couldn't be recovered
authorSam Lantinga <slouken@libsdl.org>
Thu, 27 Jul 2017 22:52:19 -0700
changeset 111615a8eabc39346
parent 11160 6b835032ce78
child 11162 a781e1dd03da
Fixed infinite recursion if the WASAPI audio device couldn't be recovered
src/audio/wasapi/SDL_wasapi.c
     1.1 --- a/src/audio/wasapi/SDL_wasapi.c	Thu Jul 27 02:41:58 2017 -0700
     1.2 +++ b/src/audio/wasapi/SDL_wasapi.c	Thu Jul 27 22:52:19 2017 -0700
     1.3 @@ -605,24 +605,22 @@
     1.4  static void
     1.5  WASAPI_FlushCapture(_THIS)
     1.6  {
     1.7 -    if (RecoverWasapiIfLost(this)) {
     1.8 -        BYTE *ptr = NULL;
     1.9 -        UINT32 frames = 0;
    1.10 -        DWORD flags = 0;
    1.11 +    BYTE *ptr = NULL;
    1.12 +    UINT32 frames = 0;
    1.13 +    DWORD flags = 0;
    1.14  
    1.15 -        /* just read until we stop getting packets, throwing them away. */
    1.16 -        while (SDL_TRUE) {
    1.17 -            const HRESULT ret = IAudioCaptureClient_GetBuffer(this->hidden->capture, &ptr, &frames, &flags, NULL, NULL);
    1.18 -            if (ret == AUDCLNT_S_BUFFER_EMPTY) {
    1.19 -                break;  /* no more buffered data; we're done. */
    1.20 -            } else if (WasapiFailed(this, ret)) {
    1.21 -                break;  /* failed for some other reason, abort. */
    1.22 -            } else if (WasapiFailed(this, IAudioCaptureClient_ReleaseBuffer(this->hidden->capture, frames))) {
    1.23 -                break;  /* something broke. */
    1.24 -            }
    1.25 +    /* just read until we stop getting packets, throwing them away. */
    1.26 +    while (SDL_TRUE) {
    1.27 +        const HRESULT ret = IAudioCaptureClient_GetBuffer(this->hidden->capture, &ptr, &frames, &flags, NULL, NULL);
    1.28 +        if (ret == AUDCLNT_S_BUFFER_EMPTY) {
    1.29 +            break;  /* no more buffered data; we're done. */
    1.30 +        } else if (WasapiFailed(this, ret)) {
    1.31 +            break;  /* failed for some other reason, abort. */
    1.32 +        } else if (WasapiFailed(this, IAudioCaptureClient_ReleaseBuffer(this->hidden->capture, frames))) {
    1.33 +            break;  /* something broke. */
    1.34          }
    1.35 -        SDL_AudioStreamClear(this->hidden->capturestream);
    1.36      }
    1.37 +    SDL_AudioStreamClear(this->hidden->capturestream);
    1.38  }
    1.39  
    1.40  static void