output/wasapi: release the COMWorker if OpenDevice() fails

Fixes assertion failure in the Thread destructor.
This commit is contained in:
Max Kellermann 2021-03-05 19:13:38 +01:00
parent 17f7098e27
commit 8b41c4f384
1 changed files with 7 additions and 1 deletions

View File

@ -205,7 +205,13 @@ public:
WasapiOutput(const ConfigBlock &block);
void Enable() override {
COMWorker::Aquire();
COMWorker::Async([&]() { OpenDevice(); }).get();
try {
COMWorker::Async([&]() { OpenDevice(); }).get();
} catch (...) {
COMWorker::Release();
throw;
}
}
void Disable() noexcept override {
COMWorker::Async([&]() { DoDisable(); }).get();