mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
Merge pull request #11306 from AdmiralCurtiss/cubeb-coinit-fixes
Correctly call CoUninitialize() on Cubeb helper class destruction.
This commit is contained in:
commit
c8d30968f3
@ -46,6 +46,7 @@ CubebStream::CubebStream()
|
||||
Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); });
|
||||
auto result = ::CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
|
||||
m_coinit_success = result == S_OK;
|
||||
m_should_couninit = result == S_OK || result == S_FALSE;
|
||||
});
|
||||
sync_event.Wait();
|
||||
}
|
||||
@ -137,11 +138,12 @@ CubebStream::~CubebStream()
|
||||
cubeb_stream_stop(m_stream);
|
||||
cubeb_stream_destroy(m_stream);
|
||||
#ifdef _WIN32
|
||||
if (m_coinit_success)
|
||||
if (m_should_couninit)
|
||||
{
|
||||
m_coinit_success = false;
|
||||
m_should_couninit = false;
|
||||
CoUninitialize();
|
||||
}
|
||||
m_coinit_success = false;
|
||||
});
|
||||
sync_event.Wait();
|
||||
#endif
|
||||
|
@ -37,6 +37,7 @@ private:
|
||||
#ifdef _WIN32
|
||||
Common::WorkQueueThread<std::function<void()>> m_work_queue;
|
||||
bool m_coinit_success = false;
|
||||
bool m_should_couninit = false;
|
||||
#endif
|
||||
|
||||
static long DataCallback(cubeb_stream* stream, void* user_data, const void* /*input_buffer*/,
|
||||
|
@ -221,6 +221,7 @@ CEXIMic::CEXIMic(int index)
|
||||
Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); });
|
||||
auto result = ::CoInitializeEx(nullptr, COINIT_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
|
||||
m_coinit_success = result == S_OK;
|
||||
m_should_couninit = result == S_OK || result == S_FALSE;
|
||||
});
|
||||
sync_event.Wait();
|
||||
#endif
|
||||
@ -231,6 +232,20 @@ CEXIMic::CEXIMic(int index)
|
||||
CEXIMic::~CEXIMic()
|
||||
{
|
||||
StreamTerminate();
|
||||
|
||||
#ifdef _WIN32
|
||||
if (m_should_couninit)
|
||||
{
|
||||
Common::Event sync_event;
|
||||
m_work_queue.EmplaceItem([this, &sync_event] {
|
||||
Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); });
|
||||
m_should_couninit = false;
|
||||
CoUninitialize();
|
||||
});
|
||||
sync_event.Wait();
|
||||
}
|
||||
m_coinit_success = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CEXIMic::IsPresent() const
|
||||
|
@ -104,6 +104,7 @@ private:
|
||||
#ifdef _WIN32
|
||||
Common::WorkQueueThread<std::function<void()>> m_work_queue;
|
||||
bool m_coinit_success = false;
|
||||
bool m_should_couninit = false;
|
||||
#endif
|
||||
};
|
||||
} // namespace ExpansionInterface
|
||||
|
Loading…
Reference in New Issue
Block a user