mirror of https://github.com/encounter/SDL.git
wasapi: Deal with AUDCLNT_S_BUFFER_EMPTY when flushing audio device.
This commit is contained in:
parent
4073a6694f
commit
adabc38439
|
@ -609,9 +609,14 @@ WASAPI_FlushCapture(_THIS)
|
||||||
DWORD flags = 0;
|
DWORD flags = 0;
|
||||||
|
|
||||||
/* just read until we stop getting packets, throwing them away. */
|
/* just read until we stop getting packets, throwing them away. */
|
||||||
while (!WasapiFailed(this, IAudioCaptureClient_GetBuffer(this->hidden->capture, &ptr, &frames, &flags, NULL, NULL))) {
|
while (SDL_TRUE) {
|
||||||
if (WasapiFailed(this, IAudioCaptureClient_ReleaseBuffer(this->hidden->capture, frames))) {
|
const HRESULT ret = IAudioCaptureClient_GetBuffer(this->hidden->capture, &ptr, &frames, &flags, NULL, NULL));
|
||||||
break;
|
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);
|
||||||
|
|
Loading…
Reference in New Issue