mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-09-10 14:07:25 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 242a04c324 | |||
| b345f7615a |
@@ -8,7 +8,6 @@
|
||||
#include "audio_core/opus/hardware_opus.h"
|
||||
#include "audio_core/opus/parameters.h"
|
||||
#include "common/alignment.h"
|
||||
#include "common/scope_exit.h"
|
||||
#include "common/swap.h"
|
||||
#include "core/core.h"
|
||||
|
||||
@@ -29,18 +28,10 @@ OpusDecoder::OpusDecoder(Core::System& system_, HardwareOpus& hardware_opus_)
|
||||
OpusDecoder::~OpusDecoder() {
|
||||
if (decode_object_initialized) {
|
||||
hardware_opus.ShutdownDecodeObject(shared_buffer.data(), shared_buffer.size());
|
||||
hardware_opus.UnregisterDecoder(this);
|
||||
}
|
||||
}
|
||||
|
||||
Result OpusDecoder::Initialize(const OpusParametersEx& params, Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size) {
|
||||
R_TRY(hardware_opus.RegisterDecoder(this));
|
||||
SCOPE_EXIT {
|
||||
if (!decode_object_initialized) {
|
||||
hardware_opus.UnregisterDecoder(this);
|
||||
}
|
||||
};
|
||||
|
||||
auto frame_size{params.use_large_frame_size ? 5760 : 1920};
|
||||
shared_buffer.resize(transfer_memory_size);
|
||||
shared_memory_mapped = true;
|
||||
@@ -70,13 +61,6 @@ Result OpusDecoder::Initialize(const OpusParametersEx& params, Kernel::KTransfer
|
||||
}
|
||||
|
||||
Result OpusDecoder::Initialize(const OpusMultiStreamParametersEx& params, Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size) {
|
||||
R_TRY(hardware_opus.RegisterDecoder(this));
|
||||
SCOPE_EXIT {
|
||||
if (!decode_object_initialized) {
|
||||
hardware_opus.UnregisterDecoder(this);
|
||||
}
|
||||
};
|
||||
|
||||
auto frame_size{params.use_large_frame_size ? 5760 : 1920};
|
||||
shared_buffer.resize(transfer_memory_size, 0);
|
||||
shared_memory_mapped = true;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
// 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"
|
||||
@@ -46,25 +45,6 @@ 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;
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
#include <mutex>
|
||||
#include <opus.h>
|
||||
|
||||
@@ -13,12 +12,9 @@
|
||||
#include "core/hle/service/audio/errors.h"
|
||||
|
||||
namespace AudioCore::OpusDecoder {
|
||||
class OpusDecoder;
|
||||
class HardwareOpus {
|
||||
public:
|
||||
HardwareOpus(Core::System& system);
|
||||
Result RegisterDecoder(OpusDecoder* decoder);
|
||||
void UnregisterDecoder(OpusDecoder* decoder);
|
||||
|
||||
u32 GetWorkBufferSize(u32 channel);
|
||||
u32 GetWorkBufferSizeForMultiStream(u32 total_stream_count, u32 stereo_stream_count);
|
||||
@@ -43,7 +39,6 @@ public:
|
||||
private:
|
||||
Core::System& system;
|
||||
std::mutex mutex;
|
||||
std::array<OpusDecoder*, 24> decoders{};
|
||||
ADSP::OpusDecoder::OpusDecoder& opus_decoder;
|
||||
ADSP::OpusDecoder::SharedMemory shared_memory;
|
||||
};
|
||||
|
||||
@@ -33,7 +33,6 @@ constexpr Result ResultLibOpusInternalError{ErrorModule::HwOpus, 4};
|
||||
constexpr Result ResultBufferTooSmall{ErrorModule::HwOpus, 3};
|
||||
constexpr Result ResultLibOpusBadArg{ErrorModule::HwOpus, 2};
|
||||
constexpr Result ResultInvalidOpusDSPReturnCode{ErrorModule::HwOpus, 259};
|
||||
constexpr Result ResultOutOfOpusDecoders{ErrorModule::HwOpus, 385};
|
||||
constexpr Result ResultInvalidOpusSampleRate{ErrorModule::HwOpus, 1001};
|
||||
constexpr Result ResultInvalidOpusChannelCount{ErrorModule::HwOpus, 1002};
|
||||
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -28,11 +31,6 @@ struct FuncTraits<ReturnType_ (*)(Args...)> {
|
||||
using ArgType = std::tuple_element_t<I, std::tuple<Args...>>;
|
||||
};
|
||||
|
||||
template <auto func, typename... Args>
|
||||
void SetDefinition(EmitContext& ctx, IR::Inst* inst, Args... args) {
|
||||
inst->SetDefinition<Id>(func(ctx, std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
template <typename ArgType>
|
||||
auto Arg(EmitContext& ctx, const IR::Value& arg) {
|
||||
if constexpr (std::is_same_v<ArgType, std::string_view>) {
|
||||
@@ -53,21 +51,10 @@ auto Arg(EmitContext& ctx, const IR::Value& arg) {
|
||||
template <auto func, bool is_first_arg_inst, size_t... I>
|
||||
void Invoke(EmitContext& ctx, IR::Inst* inst, std::index_sequence<I...>) {
|
||||
using Traits = FuncTraits<decltype(func)>;
|
||||
if constexpr (std::is_same_v<typename Traits::ReturnType, Id>) {
|
||||
if constexpr (is_first_arg_inst) {
|
||||
SetDefinition<func>(
|
||||
ctx, inst, *inst,
|
||||
Arg<typename Traits::template ArgType<I + 2>>(ctx, inst->Arg(I))...);
|
||||
} else {
|
||||
SetDefinition<func>(
|
||||
ctx, inst, Arg<typename Traits::template ArgType<I + 1>>(ctx, inst->Arg(I))...);
|
||||
}
|
||||
if constexpr (is_first_arg_inst) {
|
||||
func(ctx, *inst, Arg<typename Traits::template ArgType<I + 2>>(ctx, inst->Arg(I))...);
|
||||
} else {
|
||||
if constexpr (is_first_arg_inst) {
|
||||
func(ctx, *inst, Arg<typename Traits::template ArgType<I + 2>>(ctx, inst->Arg(I))...);
|
||||
} else {
|
||||
func(ctx, Arg<typename Traits::template ArgType<I + 1>>(ctx, inst->Arg(I))...);
|
||||
}
|
||||
func(ctx, Arg<typename Traits::template ArgType<I + 1>>(ctx, inst->Arg(I))...);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user