diff options
Diffstat (limited to '')
| -rw-r--r-- | src/audio_core/audio_core.cpp | 8 | ||||
| -rw-r--r-- | src/audio_core/audio_core.h | 14 | ||||
| -rw-r--r-- | src/audio_core/sink/sink_stream.cpp | 8 | ||||
| -rw-r--r-- | src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | 7 |
4 files changed, 35 insertions, 2 deletions
diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index cf7e763e6..9feec1829 100644 --- a/src/audio_core/audio_core.cpp +++ b/src/audio_core/audio_core.cpp | |||
| @@ -57,4 +57,12 @@ void AudioCore::PauseSinks(const bool pausing) const { | |||
| 57 | } | 57 | } |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | void AudioCore::SetNVDECActive(bool active) { | ||
| 61 | nvdec_active = active; | ||
| 62 | } | ||
| 63 | |||
| 64 | bool AudioCore::IsNVDECActive() const { | ||
| 65 | return nvdec_active; | ||
| 66 | } | ||
| 67 | |||
| 60 | } // namespace AudioCore | 68 | } // namespace AudioCore |
diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index fd1e43356..ac9afefaa 100644 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h | |||
| @@ -65,6 +65,18 @@ public: | |||
| 65 | */ | 65 | */ |
| 66 | void PauseSinks(bool pausing) const; | 66 | void PauseSinks(bool pausing) const; |
| 67 | 67 | ||
| 68 | /** | ||
| 69 | * Toggle NVDEC state, used to avoid stall in playback. | ||
| 70 | * | ||
| 71 | * @param active - Set true if nvdec is active, otherwise false. | ||
| 72 | */ | ||
| 73 | void SetNVDECActive(bool active); | ||
| 74 | |||
| 75 | /** | ||
| 76 | * Get NVDEC state. | ||
| 77 | */ | ||
| 78 | bool IsNVDECActive() const; | ||
| 79 | |||
| 68 | private: | 80 | private: |
| 69 | /** | 81 | /** |
| 70 | * Create the sinks on startup. | 82 | * Create the sinks on startup. |
| @@ -79,6 +91,8 @@ private: | |||
| 79 | std::unique_ptr<Sink::Sink> input_sink; | 91 | std::unique_ptr<Sink::Sink> input_sink; |
| 80 | /// The ADSP in the sysmodule | 92 | /// The ADSP in the sysmodule |
| 81 | std::unique_ptr<AudioRenderer::ADSP::ADSP> adsp; | 93 | std::unique_ptr<AudioRenderer::ADSP::ADSP> adsp; |
| 94 | /// Is NVDec currently active? | ||
| 95 | bool nvdec_active{false}; | ||
| 82 | }; | 96 | }; |
| 83 | 97 | ||
| 84 | } // namespace AudioCore | 98 | } // namespace AudioCore |
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 3770c515d..24636e512 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <span> | 9 | #include <span> |
| 10 | #include <vector> | 10 | #include <vector> |
| 11 | 11 | ||
| 12 | #include "audio_core/audio_core.h" | ||
| 12 | #include "audio_core/common/common.h" | 13 | #include "audio_core/common/common.h" |
| 13 | #include "audio_core/sink/sink_stream.h" | 14 | #include "audio_core/sink/sink_stream.h" |
| 14 | #include "common/common_types.h" | 15 | #include "common/common_types.h" |
| @@ -194,7 +195,12 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz | |||
| 194 | const std::size_t frame_size_bytes = frame_size * sizeof(s16); | 195 | const std::size_t frame_size_bytes = frame_size * sizeof(s16); |
| 195 | size_t frames_written{0}; | 196 | size_t frames_written{0}; |
| 196 | 197 | ||
| 197 | if (queued_buffers > max_queue_size) { | 198 | // Due to many frames being queued up with nvdec (5 frames or so?), a lot of buffers also get |
| 199 | // queued up (30+) but not all at once, which causes constant stalling here, so just let the | ||
| 200 | // video play out without attempting to stall. | ||
| 201 | // Can hopefully remove this later with a more complete NVDEC implementation. | ||
| 202 | const auto nvdec_active{system.AudioCore().IsNVDECActive()}; | ||
| 203 | if (!nvdec_active && queued_buffers > max_queue_size) { | ||
| 198 | Stall(); | 204 | Stall(); |
| 199 | } | 205 | } |
| 200 | 206 | ||
diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index 2a5128c60..a7385fce8 100644 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "audio_core/audio_core.h" | ||
| 4 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 5 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 6 | #include "core/core.h" | 7 | #include "core/core.h" |
| @@ -65,7 +66,10 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, const std::vector<u8>& | |||
| 65 | return NvResult::NotImplemented; | 66 | return NvResult::NotImplemented; |
| 66 | } | 67 | } |
| 67 | 68 | ||
| 68 | void nvhost_nvdec::OnOpen(DeviceFD fd) {} | 69 | void nvhost_nvdec::OnOpen(DeviceFD fd) { |
| 70 | LOG_INFO(Service_NVDRV, "NVDEC video stream started"); | ||
| 71 | system.AudioCore().SetNVDECActive(true); | ||
| 72 | } | ||
| 69 | 73 | ||
| 70 | void nvhost_nvdec::OnClose(DeviceFD fd) { | 74 | void nvhost_nvdec::OnClose(DeviceFD fd) { |
| 71 | LOG_INFO(Service_NVDRV, "NVDEC video stream ended"); | 75 | LOG_INFO(Service_NVDRV, "NVDEC video stream ended"); |
| @@ -73,6 +77,7 @@ void nvhost_nvdec::OnClose(DeviceFD fd) { | |||
| 73 | if (iter != fd_to_id.end()) { | 77 | if (iter != fd_to_id.end()) { |
| 74 | system.GPU().ClearCdmaInstance(iter->second); | 78 | system.GPU().ClearCdmaInstance(iter->second); |
| 75 | } | 79 | } |
| 80 | system.AudioCore().SetNVDECActive(false); | ||
| 76 | } | 81 | } |
| 77 | 82 | ||
| 78 | } // namespace Service::Nvidia::Devices | 83 | } // namespace Service::Nvidia::Devices |