From 50d0cc2716b63e2e63b56be56845ed838e505c33 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Jun 2021 18:22:10 -0700 Subject: [PATCH 1/5] audio_core: common: Bump audio revision to 9. - This is used in fw 12.x.x games. --- src/audio_core/common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/audio_core/common.h b/src/audio_core/common.h index fe546c55d0..1ab5375888 100644 --- a/src/audio_core/common.h +++ b/src/audio_core/common.h @@ -15,7 +15,7 @@ constexpr ResultCode ERR_INVALID_PARAMETERS{ErrorModule::Audio, 41}; constexpr ResultCode ERR_SPLITTER_SORT_FAILED{ErrorModule::Audio, 43}; } // namespace Audren -constexpr u32_le CURRENT_PROCESS_REVISION = Common::MakeMagic('R', 'E', 'V', '8'); +constexpr u32_le CURRENT_PROCESS_REVISION = Common::MakeMagic('R', 'E', 'V', '9'); constexpr std::size_t MAX_MIX_BUFFERS = 24; constexpr std::size_t MAX_BIQUAD_FILTERS = 2; constexpr std::size_t MAX_CHANNEL_COUNT = 6; From d1ba4a2db2b9d5c635a2673d1bc843a59ddf1b7e Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Jun 2021 18:22:53 -0700 Subject: [PATCH 2/5] hle: service: aoc: Stub GetAddOnContentListChangedEventWithProcessId. - This is used by the latest update of Doom Eternal. --- src/core/hle/service/aoc/aoc_u.cpp | 10 +++++++++- src/core/hle/service/aoc/aoc_u.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index fec704c65e..dd945e058a 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp @@ -117,7 +117,7 @@ AOC_U::AOC_U(Core::System& system_) {7, &AOC_U::PrepareAddOnContent, "PrepareAddOnContent"}, {8, &AOC_U::GetAddOnContentListChangedEvent, "GetAddOnContentListChangedEvent"}, {9, nullptr, "GetAddOnContentLostErrorCode"}, - {10, nullptr, "GetAddOnContentListChangedEventWithProcessId"}, + {10, &AOC_U::GetAddOnContentListChangedEventWithProcessId, "GetAddOnContentListChangedEventWithProcessId"}, {100, &AOC_U::CreateEcPurchasedEventManager, "CreateEcPurchasedEventManager"}, {101, &AOC_U::CreatePermanentEcPurchasedEventManager, "CreatePermanentEcPurchasedEventManager"}, {110, nullptr, "CreateContentsServiceManager"}, @@ -257,6 +257,14 @@ void AOC_U::GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx) { rb.PushCopyObjects(aoc_change_event.GetReadableEvent()); } +void AOC_U::GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx) { + LOG_WARNING(Service_AOC, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(aoc_change_event.GetReadableEvent()); +} + void AOC_U::CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx) { LOG_WARNING(Service_AOC, "(STUBBED) called"); diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h index 65095baa20..bb6ffb8eb9 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h @@ -28,6 +28,7 @@ private: void GetAddOnContentBaseId(Kernel::HLERequestContext& ctx); void PrepareAddOnContent(Kernel::HLERequestContext& ctx); void GetAddOnContentListChangedEvent(Kernel::HLERequestContext& ctx); + void GetAddOnContentListChangedEventWithProcessId(Kernel::HLERequestContext& ctx); void CreateEcPurchasedEventManager(Kernel::HLERequestContext& ctx); void CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ctx); From 3565e32f4d8ae28ae69dbb59e4ecad4fc8155a54 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Jun 2021 18:25:37 -0700 Subject: [PATCH 3/5] hle: service: hwopus: Implement GetWorkBufferSizeEx and OpenHardwareOpusDecoderEx. - This is used by the latest update of Doom Eternal. --- src/core/hle/service/audio/hwopus.cpp | 16 ++++++++++++---- src/core/hle/service/audio/hwopus.h | 4 +++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 10e6f7a64a..a6e030a4a3 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp @@ -253,7 +253,11 @@ void HwOpus::GetWorkBufferSize(Kernel::HLERequestContext& ctx) { rb.Push(worker_buffer_sz); } -void HwOpus::OpenOpusDecoder(Kernel::HLERequestContext& ctx) { +void HwOpus::GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx) { + GetWorkBufferSize(ctx); +} + +void HwOpus::OpenHardwareOpusDecoder(Kernel::HLERequestContext& ctx) { IPC::RequestParser rp{ctx}; const auto sample_rate = rp.Pop(); const auto channel_count = rp.Pop(); @@ -291,14 +295,18 @@ void HwOpus::OpenOpusDecoder(Kernel::HLERequestContext& ctx) { system, OpusDecoderState{std::move(decoder), sample_rate, channel_count}); } +void HwOpus::OpenHardwareOpusDecoderEx(Kernel::HLERequestContext& ctx) { + OpenHardwareOpusDecoder(ctx); +} + HwOpus::HwOpus(Core::System& system_) : ServiceFramework{system_, "hwopus"} { static const FunctionInfo functions[] = { - {0, &HwOpus::OpenOpusDecoder, "OpenOpusDecoder"}, + {0, &HwOpus::OpenHardwareOpusDecoder, "OpenHardwareOpusDecoder"}, {1, &HwOpus::GetWorkBufferSize, "GetWorkBufferSize"}, {2, nullptr, "OpenOpusDecoderForMultiStream"}, {3, nullptr, "GetWorkBufferSizeForMultiStream"}, - {4, nullptr, "OpenHardwareOpusDecoderEx"}, - {5, nullptr, "GetWorkBufferSizeEx"}, + {4, &HwOpus::OpenHardwareOpusDecoderEx, "OpenHardwareOpusDecoderEx"}, + {5, &HwOpus::GetWorkBufferSizeEx, "GetWorkBufferSizeEx"}, {6, nullptr, "OpenHardwareOpusDecoderForMultiStreamEx"}, {7, nullptr, "GetWorkBufferSizeForMultiStreamEx"}, }; diff --git a/src/core/hle/service/audio/hwopus.h b/src/core/hle/service/audio/hwopus.h index 4f921f18ed..b74824ff32 100644 --- a/src/core/hle/service/audio/hwopus.h +++ b/src/core/hle/service/audio/hwopus.h @@ -18,8 +18,10 @@ public: ~HwOpus() override; private: - void OpenOpusDecoder(Kernel::HLERequestContext& ctx); + void OpenHardwareOpusDecoder(Kernel::HLERequestContext& ctx); + void OpenHardwareOpusDecoderEx(Kernel::HLERequestContext& ctx); void GetWorkBufferSize(Kernel::HLERequestContext& ctx); + void GetWorkBufferSizeEx(Kernel::HLERequestContext& ctx); }; } // namespace Service::Audio From 982be246abcc2e672442397ca2a256c12aacc2b0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Thu, 24 Jun 2021 18:39:43 -0700 Subject: [PATCH 4/5] hle: hle_helpers: Skip data payload offset checks on TIPC requests. - TIPC does not use this. --- src/core/hle/ipc_helpers.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/core/hle/ipc_helpers.h b/src/core/hle/ipc_helpers.h index 61bda37865..ceff2532dd 100644 --- a/src/core/hle/ipc_helpers.h +++ b/src/core/hle/ipc_helpers.h @@ -345,8 +345,12 @@ public: explicit RequestParser(u32* command_buffer) : RequestHelperBase(command_buffer) {} explicit RequestParser(Kernel::HLERequestContext& ctx) : RequestHelperBase(ctx) { - ASSERT_MSG(ctx.GetDataPayloadOffset(), "context is incomplete"); - Skip(ctx.GetDataPayloadOffset(), false); + // TIPC does not have data payload offset + if (!ctx.IsTipc()) { + ASSERT_MSG(ctx.GetDataPayloadOffset(), "context is incomplete"); + Skip(ctx.GetDataPayloadOffset(), false); + } + // Skip the u64 command id, it's already stored in the context static constexpr u32 CommandIdSize = 2; Skip(CommandIdSize, false); From 36d581ec73454a50b86c99539e2c60383f9c9bf0 Mon Sep 17 00:00:00 2001 From: bunnei Date: Sat, 26 Jun 2021 00:38:08 -0700 Subject: [PATCH 5/5] hle: service: hwopus: OpenHardwareOpusDecoderEx: Remove unused buffer size. --- src/core/hle/service/audio/hwopus.cpp | 31 ++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index a6e030a4a3..33a6dbbb6e 100644 --- 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"} {