summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-01-29 18:15:29 -0500
committerGravatar Lioncash2019-01-29 22:53:35 -0500
commit07b86dc28cbddacedbb6f5985f9c522f88e68b1a (patch)
tree54903271274d351dc8c366182f12a1eb423fa78d /src
parenthwopus: Replace std::optional<std::reference_wrapper<u64>> with u64* (diff)
downloadyuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar.gz
yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar.xz
yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.zip
hwopus: Deduplicate the decoding code within DecodeInterleavedOld and DecodeInterleavedWithPerfOld
Keeps the logic in one spot for use by both functions.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/audio/hwopus.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp
index b70c831d2..dffb890d5 100644
--- a/src/core/hle/service/audio/hwopus.cpp
+++ b/src/core/hle/service/audio/hwopus.cpp
@@ -49,43 +49,38 @@ private:
49 void DecodeInterleavedOld(Kernel::HLERequestContext& ctx) { 49 void DecodeInterleavedOld(Kernel::HLERequestContext& ctx) {
50 LOG_DEBUG(Audio, "called"); 50 LOG_DEBUG(Audio, "called");
51 51
52 u32 consumed = 0; 52 DecodeInterleavedHelper(ctx, nullptr);
53 u32 sample_count = 0;
54 std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16));
55 if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples, nullptr)) {
56 LOG_ERROR(Audio, "Failed to decode opus data");
57 IPC::ResponseBuilder rb{ctx, 2};
58 // TODO(ogniK): Use correct error code
59 rb.Push(ResultCode(-1));
60 return;
61 }
62 IPC::ResponseBuilder rb{ctx, 4};
63 rb.Push(RESULT_SUCCESS);
64 rb.Push<u32>(consumed);
65 rb.Push<u32>(sample_count);
66 ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16));
67 } 53 }
68 54
69 void DecodeInterleavedWithPerfOld(Kernel::HLERequestContext& ctx) { 55 void DecodeInterleavedWithPerfOld(Kernel::HLERequestContext& ctx) {
70 LOG_DEBUG(Audio, "called"); 56 LOG_DEBUG(Audio, "called");
71 57
58 u64 performance = 0;
59 DecodeInterleavedHelper(ctx, &performance);
60 }
61
62 void DecodeInterleavedHelper(Kernel::HLERequestContext& ctx, u64* performance) {
72 u32 consumed = 0; 63 u32 consumed = 0;
73 u32 sample_count = 0; 64 u32 sample_count = 0;
74 u64 performance = 0;
75 std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16)); 65 std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16));
66
76 if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples, 67 if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples,
77 &performance)) { 68 performance)) {
78 LOG_ERROR(Audio, "Failed to decode opus data"); 69 LOG_ERROR(Audio, "Failed to decode opus data");
79 IPC::ResponseBuilder rb{ctx, 2}; 70 IPC::ResponseBuilder rb{ctx, 2};
80 // TODO(ogniK): Use correct error code 71 // TODO(ogniK): Use correct error code
81 rb.Push(ResultCode(-1)); 72 rb.Push(ResultCode(-1));
82 return; 73 return;
83 } 74 }
84 IPC::ResponseBuilder rb{ctx, 6}; 75
76 const u32 param_size = performance != nullptr ? 6 : 4;
77 IPC::ResponseBuilder rb{ctx, param_size};
85 rb.Push(RESULT_SUCCESS); 78 rb.Push(RESULT_SUCCESS);
86 rb.Push<u32>(consumed); 79 rb.Push<u32>(consumed);
87 rb.Push<u32>(sample_count); 80 rb.Push<u32>(sample_count);
88 rb.Push<u64>(performance); 81 if (performance) {
82 rb.Push<u64>(*performance);
83 }
89 ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16)); 84 ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16));
90 } 85 }
91 86