summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-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) {
296} 296}
297 297
298void HwOpus::OpenHardwareOpusDecoderEx(Kernel::HLERequestContext& ctx) { 298void HwOpus::OpenHardwareOpusDecoderEx(Kernel::HLERequestContext& ctx) {
299 OpenHardwareOpusDecoder(ctx); 299 IPC::RequestParser rp{ctx};
300 const auto sample_rate = rp.Pop<u32>();
301 const auto channel_count = rp.Pop<u32>();
302
303 LOG_CRITICAL(Audio, "called sample_rate={}, channel_count={}", sample_rate, channel_count);
304
305 ASSERT_MSG(sample_rate == 48000 || sample_rate == 24000 || sample_rate == 16000 ||
306 sample_rate == 12000 || sample_rate == 8000,
307 "Invalid sample rate");
308 ASSERT_MSG(channel_count == 1 || channel_count == 2, "Invalid channel count");
309
310 const int num_stereo_streams = channel_count == 2 ? 1 : 0;
311 const auto mapping_table = CreateMappingTable(channel_count);
312
313 int error = 0;
314 OpusDecoderPtr decoder{
315 opus_multistream_decoder_create(sample_rate, static_cast<int>(channel_count), 1,
316 num_stereo_streams, mapping_table.data(), &error)};
317 if (error != OPUS_OK || decoder == nullptr) {
318 LOG_ERROR(Audio, "Failed to create Opus decoder (error={}).", error);
319 IPC::ResponseBuilder rb{ctx, 2};
320 // TODO(ogniK): Use correct error code
321 rb.Push(ResultUnknown);
322 return;
323 }
324
325 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
326 rb.Push(ResultSuccess);
327 rb.PushIpcInterface<IHardwareOpusDecoderManager>(
328 system, OpusDecoderState{std::move(decoder), sample_rate, channel_count});
300} 329}
301 330
302HwOpus::HwOpus(Core::System& system_) : ServiceFramework{system_, "hwopus"} { 331HwOpus::HwOpus(Core::System& system_) : ServiceFramework{system_, "hwopus"} {