From 0826a8be7d247ab239c37458919a4e5c2634f582 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sat, 26 Jun 2021 11:24:59 +0200 Subject: [PATCH] early-access version 1830 --- README.md | 2 +- src/core/hle/service/audio/hwopus.cpp | 31 ++++++++++++++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dc64ff2a1..9466e90fe 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1829. +This is the source code for early-access 1830. ## Legal Notice diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index a6e030a4a..33a6dbbb6 100755 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -296,7 +296,36 @@ void HwOpus::OpenHardwareOpusDecoder(Kernel::HLERequestContext& ctx) { } void HwOpus::OpenHardwareOpusDecoderEx(Kernel::HLERequestContext& ctx) { - OpenHardwareOpusDecoder(ctx); + IPC::RequestParser rp{ctx}; + const auto sample_rate = rp.Pop(); + const auto channel_count = rp.Pop(); + + LOG_CRITICAL(Audio, "called sample_rate={}, channel_count={}", sample_rate, channel_count); + + ASSERT_MSG(sample_rate == 48000 || sample_rate == 24000 || sample_rate == 16000 || + sample_rate == 12000 || sample_rate == 8000, + "Invalid sample rate"); + ASSERT_MSG(channel_count == 1 || channel_count == 2, "Invalid channel count"); + + const int num_stereo_streams = channel_count == 2 ? 1 : 0; + const auto mapping_table = CreateMappingTable(channel_count); + + int error = 0; + OpusDecoderPtr decoder{ + opus_multistream_decoder_create(sample_rate, static_cast(channel_count), 1, + num_stereo_streams, mapping_table.data(), &error)}; + if (error != OPUS_OK || decoder == nullptr) { + LOG_ERROR(Audio, "Failed to create Opus decoder (error={}).", error); + IPC::ResponseBuilder rb{ctx, 2}; + // TODO(ogniK): Use correct error code + rb.Push(ResultUnknown); + return; + } + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + rb.PushIpcInterface( + system, OpusDecoderState{std::move(decoder), sample_rate, channel_count}); } HwOpus::HwOpus(Core::System& system_) : ServiceFramework{system_, "hwopus"} {