From 23bb909bc9035d823718ea98d512826d48887a40 Mon Sep 17 00:00:00 2001 From: lizzie Date: Sun, 31 May 2026 02:38:26 +0200 Subject: [PATCH] [audio_core] fix OOB copy when silencing channel on shutdown (#3969) when shutting down the emulator will silence any remaining audio from the output buffer however this is for some reason stored in an array instead of being a simple memset additionally, said array can be small enough (`frame_size_bytes > silence.size()`) to cause a funky noise to play at the end Signed-off-by: lizzie Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3969 Reviewed-by: MaranBr Reviewed-by: crueter --- src/audio_core/sink/sink_stream.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 2c41e7f2c8..cc27a09105 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -1,4 +1,4 @@ -// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project +// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project // SPDX-License-Identifier: GPL-3.0-or-later // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project @@ -177,10 +177,8 @@ void SinkStream::ProcessAudioOutAndRender(std::span output_buffer, std::siz queued_buffers.store(0); release_cv.notify_one(); } - - static constexpr std::array silence{}; for (size_t i = 0; i < num_frames; i++) - std::memcpy(&output_buffer[i * frame_size], silence.data(), frame_size_bytes); + std::memset(&output_buffer[i * frame_size], 0, frame_size_bytes); return; }