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