aboutsummaryrefslogtreecommitdiff
path: root/src/audio_core/opus/hardware_opus.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio_core/opus/hardware_opus.cpp')
-rw-r--r--src/audio_core/opus/hardware_opus.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/audio_core/opus/hardware_opus.cpp b/src/audio_core/opus/hardware_opus.cpp
index 0037a3e503..04591c10b6 100644
--- a/src/audio_core/opus/hardware_opus.cpp
+++ b/src/audio_core/opus/hardware_opus.cpp
@@ -4,6 +4,7 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <algorithm>
#include <array>
#include "audio_core/audio_core.h"
@@ -45,6 +46,25 @@ HardwareOpus::HardwareOpus(Core::System& system_)
opus_decoder.SetSharedMemory(shared_memory);
}
+Result HardwareOpus::RegisterDecoder(OpusDecoder* decoder) {
+ std::scoped_lock l{mutex};
+ const auto slot = std::ranges::find(decoders, nullptr);
+ if (slot == decoders.end()) {
+ R_THROW(ResultOutOfOpusDecoders);
+ }
+ *slot = decoder;
+ R_SUCCEED();
+}
+
+void HardwareOpus::UnregisterDecoder(OpusDecoder* decoder) {
+ std::scoped_lock l{mutex};
+ const auto slot = std::ranges::find(decoders, decoder);
+ if (slot == decoders.end()) {
+ return;
+ }
+ *slot = nullptr;
+}
+
u32 HardwareOpus::GetWorkBufferSize(u32 channel) {
if (!opus_decoder.IsRunning()) {
return 0;