mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-02-14 00:09:24 +01:00
AudioCommon/WASAPI: Simplify thread synchronization model by not detaching WASAPI handler thread
This commit is contained in:
parent
c5a372ab2a
commit
ee60be4501
@ -45,12 +45,9 @@ WASAPIStream::WASAPIStream()
|
|||||||
|
|
||||||
WASAPIStream::~WASAPIStream()
|
WASAPIStream::~WASAPIStream()
|
||||||
{
|
{
|
||||||
if (m_running)
|
|
||||||
{
|
|
||||||
m_running = false;
|
m_running = false;
|
||||||
if (m_thread.joinable())
|
if (m_thread.joinable())
|
||||||
m_thread.join();
|
m_thread.join();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WASAPIStream::isValid()
|
bool WASAPIStream::isValid()
|
||||||
@ -332,7 +329,6 @@ bool WASAPIStream::SetRunning(bool running)
|
|||||||
|
|
||||||
m_running = true;
|
m_running = true;
|
||||||
m_thread = std::thread([this] { SoundLoop(); });
|
m_thread = std::thread([this] { SoundLoop(); });
|
||||||
m_thread.detach();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -341,10 +337,6 @@ bool WASAPIStream::SetRunning(bool running)
|
|||||||
if (m_thread.joinable())
|
if (m_thread.joinable())
|
||||||
m_thread.join();
|
m_thread.join();
|
||||||
|
|
||||||
while (!m_stopped)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
m_need_data_event.reset();
|
m_need_data_event.reset();
|
||||||
m_audio_renderer.Reset();
|
m_audio_renderer.Reset();
|
||||||
m_audio_client.Reset();
|
m_audio_client.Reset();
|
||||||
@ -364,8 +356,6 @@ void WASAPIStream::SoundLoop()
|
|||||||
m_audio_renderer->ReleaseBuffer(m_frames_in_buffer, AUDCLNT_BUFFERFLAGS_SILENT);
|
m_audio_renderer->ReleaseBuffer(m_frames_in_buffer, AUDCLNT_BUFFERFLAGS_SILENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_stopped = false;
|
|
||||||
|
|
||||||
while (m_running)
|
while (m_running)
|
||||||
{
|
{
|
||||||
if (!m_audio_renderer)
|
if (!m_audio_renderer)
|
||||||
@ -383,8 +373,6 @@ void WASAPIStream::SoundLoop()
|
|||||||
|
|
||||||
m_audio_renderer->ReleaseBuffer(m_frames_in_buffer, 0);
|
m_audio_renderer->ReleaseBuffer(m_frames_in_buffer, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_stopped = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
@ -45,7 +45,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
u32 m_frames_in_buffer = 0;
|
u32 m_frames_in_buffer = 0;
|
||||||
std::atomic<bool> m_running = false;
|
std::atomic<bool> m_running = false;
|
||||||
std::atomic<bool> m_stopped = false;
|
|
||||||
std::thread m_thread;
|
std::thread m_thread;
|
||||||
|
|
||||||
// CoUninitialize must be called after all WASAPI COM objects have been destroyed,
|
// CoUninitialize must be called after all WASAPI COM objects have been destroyed,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user