summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-06-26 09:38:08 +0200
committerbunnei <bunneidev@gmail.com>2021-06-26 09:38:08 +0200
commit36d581ec73454a50b86c99539e2c60383f9c9bf0 (patch)
treeffea6746fcf46f117d875abea8913215360a1e96
parenthle: hle_helpers: Skip data payload offset checks on TIPC requests. (diff)
downloadyuzu-36d581ec73454a50b86c99539e2c60383f9c9bf0.tar
yuzu-36d581ec73454a50b86c99539e2c60383f9c9bf0.tar.gz
yuzu-36d581ec73454a50b86c99539e2c60383f9c9bf0.tar.bz2
yuzu-36d581ec73454a50b86c99539e2c60383f9c9bf0.tar.lz
yuzu-36d581ec73454a50b86c99539e2c60383f9c9bf0.tar.xz
yuzu-36d581ec73454a50b86c99539e2c60383f9c9bf0.tar.zst
yuzu-36d581ec73454a50b86c99539e2c60383f9c9bf0.zip
-rw-r--r--src/core/hle/service/audio/hwopus.cpp31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp
index a6e030a4a..33a6dbbb6 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<u32>();
+ const auto channel_count = rp.Pop<u32>();
+
+ 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<int>(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<IHardwareOpusDecoderManager>(
+ system, OpusDecoderState{std::move(decoder), sample_rate, channel_count});
}
HwOpus::HwOpus(Core::System& system_) : ServiceFramework{system_, "hwopus"} {