summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon
diff options
context:
space:
mode:
authorSilent <zdanio95@gmail.com>2019-08-17 10:08:16 +0200
committerSilent <zdanio95@gmail.com>2021-01-12 19:21:54 +0100
commitee60be45010fed98a3d28f736bcf00efb036560c (patch)
tree1a79f99ff5a0a8c6870485648a43ebd83581e082 /Source/Core/AudioCommon
parentc5a372ab2a74ff5b81c6611bbfefe3d8ddad11fd (diff)
AudioCommon/WASAPI: Simplify thread synchronization model by not detaching WASAPI handler thread
Diffstat (limited to 'Source/Core/AudioCommon')
-rw-r--r--Source/Core/AudioCommon/WASAPIStream.cpp18
-rw-r--r--Source/Core/AudioCommon/WASAPIStream.h1
2 files changed, 3 insertions, 16 deletions
diff --git a/Source/Core/AudioCommon/WASAPIStream.cpp b/Source/Core/AudioCommon/WASAPIStream.cpp
index 2abebd0e97..2d502c3f7c 100644
--- a/Source/Core/AudioCommon/WASAPIStream.cpp
+++ b/Source/Core/AudioCommon/WASAPIStream.cpp
@@ -45,12 +45,9 @@ WASAPIStream::WASAPIStream()
WASAPIStream::~WASAPIStream()
{
- if (m_running)
- {
- m_running = false;
- if (m_thread.joinable())
- m_thread.join();
- }
+ m_running = false;
+ if (m_thread.joinable())
+ m_thread.join();
}
bool WASAPIStream::isValid()
@@ -332,7 +329,6 @@ bool WASAPIStream::SetRunning(bool running)
m_running = true;
m_thread = std::thread([this] { SoundLoop(); });
- m_thread.detach();
}
else
{
@@ -341,10 +337,6 @@ bool WASAPIStream::SetRunning(bool running)
if (m_thread.joinable())
m_thread.join();
- while (!m_stopped)
- {
- }
-
m_need_data_event.reset();
m_audio_renderer.Reset();
m_audio_client.Reset();
@@ -364,8 +356,6 @@ void WASAPIStream::SoundLoop()
m_audio_renderer->ReleaseBuffer(m_frames_in_buffer, AUDCLNT_BUFFERFLAGS_SILENT);
}
- m_stopped = false;
-
while (m_running)
{
if (!m_audio_renderer)
@@ -383,8 +373,6 @@ void WASAPIStream::SoundLoop()
m_audio_renderer->ReleaseBuffer(m_frames_in_buffer, 0);
}
-
- m_stopped = true;
}
#endif // _WIN32
diff --git a/Source/Core/AudioCommon/WASAPIStream.h b/Source/Core/AudioCommon/WASAPIStream.h
index 39d2d5d986..b4337a378a 100644
--- a/Source/Core/AudioCommon/WASAPIStream.h
+++ b/Source/Core/AudioCommon/WASAPIStream.h
@@ -45,7 +45,6 @@ public:
private:
u32 m_frames_in_buffer = 0;
std::atomic<bool> m_running = false;
- std::atomic<bool> m_stopped = false;
std::thread m_thread;
// CoUninitialize must be called after all WASAPI COM objects have been destroyed,