Skip to content

Commit

Permalink
wasapi: Deal with AUDCLNT_S_BUFFER_EMPTY when flushing audio device.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed May 18, 2017
1 parent 4073a66 commit adabc38
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/audio/wasapi/SDL_wasapi.c
Expand Up @@ -609,9 +609,14 @@ WASAPI_FlushCapture(_THIS)
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);
Expand Down

0 comments on commit adabc38

Please sign in to comment.