summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/WASAPIStream.cpp
diff options
context:
space:
mode:
authorOatmealDome <OatmealDome@users.noreply.github.com>2026-03-15 20:09:28 -0400
committerGitHub <noreply@github.com>2026-03-15 20:09:28 -0400
commitd60942d3cb4be0a11743b1d3e6b42356ab986385 (patch)
tree9b4e2ab8c2ddaf1bea48f3282ff44b47aecf4fd5 /Source/Core/AudioCommon/WASAPIStream.cpp
parent3bc8ba683b4d5209b4d57d6f14bfa41ff1185d03 (diff)
parente8a78ed95f9f1a001bbdbb3a04a0761f251a7a29 (diff)
Merge pull request #14461 from Dentomologist/wasapistream_handle_getbuffer_errors
WASAPIStream: Fix crash when GetBuffer call fails
Diffstat (limited to 'Source/Core/AudioCommon/WASAPIStream.cpp')
-rw-r--r--Source/Core/AudioCommon/WASAPIStream.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/Source/Core/AudioCommon/WASAPIStream.cpp b/Source/Core/AudioCommon/WASAPIStream.cpp
index 0eabb910cd..afd5531ae8 100644
--- a/Source/Core/AudioCommon/WASAPIStream.cpp
+++ b/Source/Core/AudioCommon/WASAPIStream.cpp
@@ -320,14 +320,24 @@ void WASAPIStream::SoundLoop()
Common::SetCurrentThreadName("WASAPI Handler");
BYTE* data;
- m_audio_renderer->GetBuffer(m_frames_in_buffer, &data);
+ HRESULT getbuffer_result = m_audio_renderer->GetBuffer(m_frames_in_buffer, &data);
+ if (getbuffer_result != S_OK)
+ {
+ m_running.store(false, std::memory_order_relaxed);
+ return;
+ }
m_audio_renderer->ReleaseBuffer(m_frames_in_buffer, AUDCLNT_BUFFERFLAGS_SILENT);
while (m_running.load(std::memory_order_relaxed))
{
WaitForSingleObject(m_need_data_event.get(), 1000);
- m_audio_renderer->GetBuffer(m_frames_in_buffer, &data);
+ getbuffer_result = m_audio_renderer->GetBuffer(m_frames_in_buffer, &data);
+ if (getbuffer_result != S_OK)
+ {
+ m_running.store(false, std::memory_order_relaxed);
+ return;
+ }
s16* audio_data = reinterpret_cast<s16*>(data);
GetMixer()->Mix(audio_data, m_frames_in_buffer);