diff options
author | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-09-10 22:14:03 +0200 |
---|---|---|
committer | Kelebek1 <eeeedddccc@hotmail.co.uk> | 2022-09-13 14:20:35 +0200 |
commit | e93e898df528d013e2e0cfeba22e2b6d76bf99b6 (patch) | |
tree | ab921a035ce71311c126a1af7cb2bbcbfef6d024 /src/audio_core/sink/sink_stream.cpp | |
parent | Merge pull request #8842 from Kelebek1/AudOut (diff) | |
download | yuzu-e93e898df528d013e2e0cfeba22e2b6d76bf99b6.tar yuzu-e93e898df528d013e2e0cfeba22e2b6d76bf99b6.tar.gz yuzu-e93e898df528d013e2e0cfeba22e2b6d76bf99b6.tar.bz2 yuzu-e93e898df528d013e2e0cfeba22e2b6d76bf99b6.tar.lz yuzu-e93e898df528d013e2e0cfeba22e2b6d76bf99b6.tar.xz yuzu-e93e898df528d013e2e0cfeba22e2b6d76bf99b6.tar.zst yuzu-e93e898df528d013e2e0cfeba22e2b6d76bf99b6.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/sink/sink_stream.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
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<const s16> 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<s16> 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<s16, 6> 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. |