output/wasapi: check for exceptions after Wait()

This finishes problems which occur early in the WasapiOutputThread;
previously, the error was ignored and the output blocked forever
without doing anything (and without reporting the error).
This commit is contained in:
Max Kellermann 2021-03-08 22:43:20 +01:00
parent 9ade93983c
commit 3a948515ce

View File

@ -382,6 +382,10 @@ try {
} catch (...) { } catch (...) {
error.ptr = std::current_exception(); error.ptr = std::current_exception();
error.occur.store(true); error.occur.store(true);
/* wake up the client thread which may be inside
WaitDataPoped() */
data_poped.Set();
} }
AudioOutput * AudioOutput *
@ -609,6 +613,7 @@ WasapiOutput::Play(const void *chunk, size_t size)
if (consumed_size == 0) { if (consumed_size == 0) {
assert(is_started); assert(is_started);
thread->Wait(); thread->Wait();
thread->CheckException();
if (!not_interrupted.test_and_set()) { if (!not_interrupted.test_and_set()) {
throw AudioOutputInterrupted{}; throw AudioOutputInterrupted{};
} }