mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-14 12:53:03 +00:00
hwopus: Replace std::optional<std::reference_wrapper<u64>> with u64*
This doesn't really offer anything over the use of a direct pointer, so we can just use that instead.
This commit is contained in:
parent
eb1a3c1f4a
commit
44f39bfb68
|
@ -5,7 +5,6 @@
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <opus.h>
|
#include <opus.h>
|
||||||
|
@ -53,7 +52,7 @@ private:
|
||||||
u32 consumed = 0;
|
u32 consumed = 0;
|
||||||
u32 sample_count = 0;
|
u32 sample_count = 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, nullptr)) {
|
||||||
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
|
||||||
|
@ -75,7 +74,7 @@ private:
|
||||||
u64 performance = 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
|
||||||
|
@ -90,10 +89,8 @@ private:
|
||||||
ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16));
|
ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Decoder_DecodeInterleaved(
|
bool Decoder_DecodeInterleaved(u32& consumed, u32& sample_count, const std::vector<u8>& input,
|
||||||
u32& consumed, u32& sample_count, const std::vector<u8>& input,
|
std::vector<opus_int16>& output, u64* out_performance_time) {
|
||||||
std::vector<opus_int16>& output,
|
|
||||||
std::optional<std::reference_wrapper<u64>> performance_time = std::nullopt) {
|
|
||||||
const auto start_time = std::chrono::high_resolution_clock::now();
|
const auto start_time = std::chrono::high_resolution_clock::now();
|
||||||
const std::size_t raw_output_sz = output.size() * sizeof(opus_int16);
|
const std::size_t raw_output_sz = output.size() * sizeof(opus_int16);
|
||||||
if (sizeof(OpusHeader) > input.size()) {
|
if (sizeof(OpusHeader) > input.size()) {
|
||||||
|
@ -136,8 +133,8 @@ private:
|
||||||
const auto end_time = std::chrono::high_resolution_clock::now() - start_time;
|
const auto end_time = std::chrono::high_resolution_clock::now() - start_time;
|
||||||
sample_count = out_sample_count;
|
sample_count = out_sample_count;
|
||||||
consumed = static_cast<u32>(sizeof(OpusHeader) + hdr.sz);
|
consumed = static_cast<u32>(sizeof(OpusHeader) + hdr.sz);
|
||||||
if (performance_time.has_value()) {
|
if (out_performance_time != nullptr) {
|
||||||
performance_time->get() =
|
*out_performance_time =
|
||||||
std::chrono::duration_cast<std::chrono::milliseconds>(end_time).count();
|
std::chrono::duration_cast<std::chrono::milliseconds>(end_time).count();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue