Commit a2be91ae authored by Max Kellermann's avatar Max Kellermann

output/wasapi: add method WasapiOutputThread::InterruptWaiter()

parent 57942817
...@@ -209,6 +209,10 @@ public: ...@@ -209,6 +209,10 @@ public:
data_poped.Wait(); data_poped.Wait();
} }
void InterruptWaiter() noexcept {
data_poped.Set();
}
void CheckException() { void CheckException() {
if (error.occur.load()) { if (error.occur.load()) {
std::rethrow_exception(error.ptr); std::rethrow_exception(error.ptr);
...@@ -395,7 +399,7 @@ try { ...@@ -395,7 +399,7 @@ try {
new_data_size = spsc_buffer.pop(data, write_size); new_data_size = spsc_buffer.pop(data, write_size);
std::fill_n(data + new_data_size, std::fill_n(data + new_data_size,
write_size - new_data_size, 0); write_size - new_data_size, 0);
data_poped.Set(); InterruptWaiter();
} else { } else {
mode = AUDCLNT_BUFFERFLAGS_SILENT; mode = AUDCLNT_BUFFERFLAGS_SILENT;
FormatDebug(wasapi_output_domain, FormatDebug(wasapi_output_domain,
...@@ -406,9 +410,8 @@ try { ...@@ -406,9 +410,8 @@ try {
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 /* wake up the client thread which may be inside Wait() */
WaitDataPoped() */ InterruptWaiter();
data_poped.Set();
} }
AudioOutput * AudioOutput *
...@@ -661,7 +664,7 @@ WasapiOutput::Interrupt() noexcept ...@@ -661,7 +664,7 @@ WasapiOutput::Interrupt() noexcept
{ {
if (thread) { if (thread) {
not_interrupted.clear(); not_interrupted.clear();
thread->data_poped.Set(); thread->InterruptWaiter();
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment