mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 13:12:50 +00:00
hwopus: Deduplicate the decoding code within DecodeInterleavedOld and DecodeInterleavedWithPerfOld
Keeps the logic in one spot for use by both functions.
This commit is contained in:
parent
44f39bfb68
commit
07b86dc28c
|
@ -49,43 +49,38 @@ private:
|
||||||
void DecodeInterleavedOld(Kernel::HLERequestContext& ctx) {
|
void DecodeInterleavedOld(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Audio, "called");
|
LOG_DEBUG(Audio, "called");
|
||||||
|
|
||||||
u32 consumed = 0;
|
DecodeInterleavedHelper(ctx, nullptr);
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DecodeInterleavedWithPerfOld(Kernel::HLERequestContext& ctx) {
|
void DecodeInterleavedWithPerfOld(Kernel::HLERequestContext& ctx) {
|
||||||
LOG_DEBUG(Audio, "called");
|
LOG_DEBUG(Audio, "called");
|
||||||
|
|
||||||
|
u64 performance = 0;
|
||||||
|
DecodeInterleavedHelper(ctx, &performance);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DecodeInterleavedHelper(Kernel::HLERequestContext& ctx, u64* performance) {
|
||||||
u32 consumed = 0;
|
u32 consumed = 0;
|
||||||
u32 sample_count = 0;
|
u32 sample_count = 0;
|
||||||
u64 performance = 0;
|
|
||||||
std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16));
|
std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16));
|
||||||
|
|
||||||
if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples,
|
if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples,
|
||||||
&performance)) {
|
performance)) {
|
||||||
LOG_ERROR(Audio, "Failed to decode opus data");
|
LOG_ERROR(Audio, "Failed to decode opus data");
|
||||||
IPC::ResponseBuilder rb{ctx, 2};
|
IPC::ResponseBuilder rb{ctx, 2};
|
||||||
// TODO(ogniK): Use correct error code
|
// TODO(ogniK): Use correct error code
|
||||||
rb.Push(ResultCode(-1));
|
rb.Push(ResultCode(-1));
|
||||||
return;
|
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(RESULT_SUCCESS);
|
||||||
rb.Push<u32>(consumed);
|
rb.Push<u32>(consumed);
|
||||||
rb.Push<u32>(sample_count);
|
rb.Push<u32>(sample_count);
|
||||||
rb.Push<u64>(performance);
|
if (performance) {
|
||||||
|
rb.Push<u64>(*performance);
|
||||||
|
}
|
||||||
ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16));
|
ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue