diff options
| author | Jordan Woyak <jordan.woyak@gmail.com> | 2025-11-07 16:31:46 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-11-07 16:31:46 -0600 |
| commit | 51cd0a676a7979f31751af28485c8cfcd9e5a483 (patch) | |
| tree | b106252ae46b5b2786ae45f43698658f0ebb3fc8 /Source/Core/AudioCommon/CubebStream.cpp | |
| parent | 5ed4823ebc255f637fc7981e694039eee3c8cb84 (diff) | |
| parent | 3b97a7bded04912e97bd510209a52d859e08d006 (diff) | |
Merge pull request #14079 from Dentomologist/use_asyncworkthread_pushblocking_instead_of_sync_event
CubebStream: Use WorkQueueThread::PushBlocking instead of sync_event
Diffstat (limited to 'Source/Core/AudioCommon/CubebStream.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/CubebStream.cpp | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/Source/Core/AudioCommon/CubebStream.cpp b/Source/Core/AudioCommon/CubebStream.cpp index e602691a38..1f7fb5cf45 100644 --- a/Source/Core/AudioCommon/CubebStream.cpp +++ b/Source/Core/AudioCommon/CubebStream.cpp @@ -40,14 +40,11 @@ CubebStream::CubebStream() #ifdef _WIN32 : m_work_queue("Cubeb Worker") { - Common::Event sync_event; - m_work_queue.Push([this, &sync_event] { - Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); }); + m_work_queue.PushBlocking([this] { auto const 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(); } #else = default; @@ -60,11 +57,8 @@ bool CubebStream::Init() #ifdef _WIN32 if (!m_coinit_success) return false; - Common::Event sync_event; - m_work_queue.Push([this, &return_value, &sync_event] { - Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); }); + m_work_queue.PushBlocking([this, &return_value] { #endif - m_ctx = CubebUtils::GetContext(); if (m_ctx) { @@ -98,7 +92,6 @@ bool CubebStream::Init() #ifdef _WIN32 }); - sync_event.Wait(); #endif return return_value; @@ -111,9 +104,7 @@ bool CubebStream::SetRunning(bool running) #ifdef _WIN32 if (!m_coinit_success) return false; - Common::Event sync_event; - m_work_queue.Push([this, running, &return_value, &sync_event] { - Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); }); + m_work_queue.PushBlocking([this, running, &return_value] { #endif if (running) return_value = cubeb_stream_start(m_stream) == CUBEB_OK; @@ -121,7 +112,6 @@ bool CubebStream::SetRunning(bool running) return_value = cubeb_stream_stop(m_stream) == CUBEB_OK; #ifdef _WIN32 }); - sync_event.Wait(); #endif return return_value; @@ -130,9 +120,7 @@ bool CubebStream::SetRunning(bool running) CubebStream::~CubebStream() { #ifdef _WIN32 - Common::Event sync_event; - m_work_queue.Push([this, &sync_event] { - Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); }); + m_work_queue.PushBlocking([this] { #endif cubeb_stream_stop(m_stream); cubeb_stream_destroy(m_stream); @@ -144,7 +132,6 @@ CubebStream::~CubebStream() } m_coinit_success = false; }); - sync_event.Wait(); #endif m_ctx.reset(); } @@ -154,13 +141,10 @@ void CubebStream::SetVolume(int volume) #ifdef _WIN32 if (!m_coinit_success) return; - Common::Event sync_event; - m_work_queue.Push([this, volume, &sync_event] { - Common::ScopeGuard sync_event_guard([&sync_event] { sync_event.Set(); }); + m_work_queue.PushBlocking([this, volume] { #endif cubeb_stream_set_volume(m_stream, volume / 100.0f); #ifdef _WIN32 }); - sync_event.Wait(); #endif } |
