From 47b390e3561fcd2b6a43f796259f4abf707b51ac Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 3 Jul 2021 14:29:08 +1000 Subject: [PATCH] AudioStream: Prevent buffering more frames than size --- src/common/audio_stream.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/audio_stream.cpp b/src/common/audio_stream.cpp index 6f129c33a..66a94cb57 100644 --- a/src/common/audio_stream.cpp +++ b/src/common/audio_stream.cpp @@ -115,7 +115,7 @@ void AudioStream::BeginWrite(SampleType** buffer_ptr, u32* num_frames) EnsureBuffer(requested_frames * m_channels); *buffer_ptr = m_buffer.GetWritePointer(); - *num_frames = m_buffer.GetContiguousSpace() / m_channels; + *num_frames = std::min(m_buffer_size, m_buffer.GetContiguousSpace() / m_channels); } void AudioStream::WriteFrames(const SampleType* frames, u32 num_frames)