diff options
author | Lioncash <mathew1800@gmail.com> | 2019-01-30 00:15:29 +0100 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-01-30 04:53:35 +0100 |
commit | 07b86dc28cbddacedbb6f5985f9c522f88e68b1a (patch) | |
tree | 54903271274d351dc8c366182f12a1eb423fa78d /src | |
parent | hwopus: Replace std::optional<std::reference_wrapper<u64>> with u64* (diff) | |
download | yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar.gz yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar.bz2 yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar.lz yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar.xz yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.tar.zst yuzu-07b86dc28cbddacedbb6f5985f9c522f88e68b1a.zip |
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hle/service/audio/hwopus.cpp | 33 |
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: void DecodeInterleavedOld(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Audio, "called"); - u32 consumed = 0; - u32 sample_count = 0; - std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16)); - if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples, nullptr)) { - LOG_ERROR(Audio, "Failed to decode opus data"); - IPC::ResponseBuilder rb{ctx, 2}; - // TODO(ogniK): Use correct error code - rb.Push(ResultCode(-1)); - return; - } - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(RESULT_SUCCESS); - rb.Push<u32>(consumed); - rb.Push<u32>(sample_count); - ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16)); + DecodeInterleavedHelper(ctx, nullptr); } void DecodeInterleavedWithPerfOld(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Audio, "called"); + u64 performance = 0; + DecodeInterleavedHelper(ctx, &performance); + } + + void DecodeInterleavedHelper(Kernel::HLERequestContext& ctx, u64* performance) { u32 consumed = 0; u32 sample_count = 0; - u64 performance = 0; std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16)); + if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples, - &performance)) { + performance)) { LOG_ERROR(Audio, "Failed to decode opus data"); IPC::ResponseBuilder rb{ctx, 2}; // TODO(ogniK): Use correct error code rb.Push(ResultCode(-1)); return; } - IPC::ResponseBuilder rb{ctx, 6}; + + const u32 param_size = performance != nullptr ? 6 : 4; + IPC::ResponseBuilder rb{ctx, param_size}; rb.Push(RESULT_SUCCESS); rb.Push<u32>(consumed); rb.Push<u32>(sample_count); - rb.Push<u64>(performance); + if (performance) { + rb.Push<u64>(*performance); + } ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16)); } |