From 96696e181e05bbc4a813b7ceaca093d49f7216c8 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sun, 4 Sep 2022 08:54:45 +0200 Subject: [PATCH] early-access version 2934 --- README.md | 2 +- src/audio_core/audio_core.cpp | 8 ++++++++ src/audio_core/audio_core.h | 14 ++++++++++++++ src/audio_core/sink/sink_stream.cpp | 8 +++++++- .../hle/service/nvdrv/devices/nvhost_nvdec.cpp | 7 ++++++- 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 1ccaad23a..41dba00f1 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 2933. +This is the source code for early-access 2934. ## Legal Notice diff --git a/src/audio_core/audio_core.cpp b/src/audio_core/audio_core.cpp index cf7e763e6..9feec1829 100755 --- 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 { } } +void AudioCore::SetNVDECActive(bool active) { + nvdec_active = active; +} + +bool AudioCore::IsNVDECActive() const { + return nvdec_active; +} + } // namespace AudioCore diff --git a/src/audio_core/audio_core.h b/src/audio_core/audio_core.h index fd1e43356..ac9afefaa 100755 --- a/src/audio_core/audio_core.h +++ b/src/audio_core/audio_core.h @@ -65,6 +65,18 @@ public: */ void PauseSinks(bool pausing) const; + /** + * Toggle NVDEC state, used to avoid stall in playback. + * + * @param active - Set true if nvdec is active, otherwise false. + */ + void SetNVDECActive(bool active); + + /** + * Get NVDEC state. + */ + bool IsNVDECActive() const; + private: /** * Create the sinks on startup. @@ -79,6 +91,8 @@ private: std::unique_ptr input_sink; /// The ADSP in the sysmodule std::unique_ptr adsp; + /// Is NVDec currently active? + bool nvdec_active{false}; }; } // namespace AudioCore diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 3770c515d..24636e512 100755 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -9,6 +9,7 @@ #include #include +#include "audio_core/audio_core.h" #include "audio_core/common/common.h" #include "audio_core/sink/sink_stream.h" #include "common/common_types.h" @@ -194,7 +195,12 @@ 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 (queued_buffers > max_queue_size) { + // 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. + // Can hopefully remove this later with a more complete NVDEC implementation. + const auto nvdec_active{system.AudioCore().IsNVDECActive()}; + if (!nvdec_active && queued_buffers > max_queue_size) { Stall(); } diff --git a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp index 69e9f9738..1703f9cc3 100755 --- a/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp +++ b/src/core/hle/service/nvdrv/devices/nvhost_nvdec.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "audio_core/audio_core.h" #include "common/assert.h" #include "common/logging/log.h" #include "core/core.h" @@ -66,7 +67,10 @@ NvResult nvhost_nvdec::Ioctl3(DeviceFD fd, Ioctl command, const std::vector& return NvResult::NotImplemented; } -void nvhost_nvdec::OnOpen(DeviceFD fd) {} +void nvhost_nvdec::OnOpen(DeviceFD fd) { + LOG_INFO(Service_NVDRV, "NVDEC video stream started"); + system.AudioCore().SetNVDECActive(true); +} void nvhost_nvdec::OnClose(DeviceFD fd) { LOG_INFO(Service_NVDRV, "NVDEC video stream ended"); @@ -75,6 +79,7 @@ void nvhost_nvdec::OnClose(DeviceFD fd) { if (iter != host1x_file.fd_to_id.end()) { system.GPU().ClearCdmaInstance(iter->second); } + system.AudioCore().SetNVDECActive(false); } } // namespace Service::Nvidia::Devices