From e93e898df528d013e2e0cfeba22e2b6d76bf99b6 Mon Sep 17 00:00:00 2001 From: Kelebek1 Date: Sat, 10 Sep 2022 21:14:03 +0100 Subject: Remove pause callbacks from coretiming --- src/audio_core/sink/sink_stream.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/audio_core/sink/sink_stream.cpp') diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 24636e512..59a8d69f0 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -145,6 +145,12 @@ void SinkStream::ProcessAudioIn(std::span input_buffer, std::size_t n const std::size_t frame_size_bytes = frame_size * sizeof(s16); size_t frames_written{0}; + // If we're paused or going to shut down, we don't want to consume buffers as coretiming is + // paused and we'll desync, so just return. + if (system.IsPaused() || system.IsShuttingDown()) { + return; + } + if (queued_buffers > max_queue_size) { Stall(); } @@ -195,6 +201,16 @@ void SinkStream::ProcessAudioOutAndRender(std::span output_buffer, std::siz const std::size_t frame_size_bytes = frame_size * sizeof(s16); size_t frames_written{0}; + // If we're paused or going to shut down, we don't want to consume buffers as coretiming is + // paused and we'll desync, so just play silence. + if (system.IsPaused() || system.IsShuttingDown()) { + constexpr std::array silence{}; + for (size_t i = frames_written; i < num_frames; i++) { + std::memcpy(&output_buffer[i * frame_size], &silence[0], frame_size_bytes); + } + return; + } + // Due to many frames being queued up with nvdec (5 frames or so?), a lot of buffers also get // queued up (30+) but not all at once, which causes constant stalling here, so just let the // video play out without attempting to stall. -- cgit v1.2.3