diff options
| author | 2019-01-29 17:40:27 -0500 | |
|---|---|---|
| committer | 2019-01-29 22:53:35 -0500 | |
| commit | 44f39bfb68ad727cc13ca9bef6b01748c43e68c6 (patch) | |
| tree | 6566e367509f2c228728db816b5d4085cdba03a7 /src | |
| parent | hwopus: Mark local variables as const where applicable (diff) | |
| download | yuzu-44f39bfb68ad727cc13ca9bef6b01748c43e68c6.tar.gz yuzu-44f39bfb68ad727cc13ca9bef6b01748c43e68c6.tar.xz yuzu-44f39bfb68ad727cc13ca9bef6b01748c43e68c6.zip | |
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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/audio/hwopus.cpp | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/core/hle/service/audio/hwopus.cpp b/src/core/hle/service/audio/hwopus.cpp index 67aa9f6ad..b70c831d2 100644 --- a/src/core/hle/service/audio/hwopus.cpp +++ b/src/core/hle/service/audio/hwopus.cpp | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include <chrono> | 5 | #include <chrono> |
| 6 | #include <cstring> | 6 | #include <cstring> |
| 7 | #include <memory> | 7 | #include <memory> |
| 8 | #include <optional> | ||
| 9 | #include <vector> | 8 | #include <vector> |
| 10 | 9 | ||
| 11 | #include <opus.h> | 10 | #include <opus.h> |
| @@ -53,7 +52,7 @@ private: | |||
| 53 | u32 consumed = 0; | 52 | u32 consumed = 0; |
| 54 | u32 sample_count = 0; | 53 | u32 sample_count = 0; |
| 55 | std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16)); | 54 | std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16)); |
| 56 | if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples)) { | 55 | if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples, nullptr)) { |
| 57 | LOG_ERROR(Audio, "Failed to decode opus data"); | 56 | LOG_ERROR(Audio, "Failed to decode opus data"); |
| 58 | IPC::ResponseBuilder rb{ctx, 2}; | 57 | IPC::ResponseBuilder rb{ctx, 2}; |
| 59 | // TODO(ogniK): Use correct error code | 58 | // TODO(ogniK): Use correct error code |
| @@ -75,7 +74,7 @@ private: | |||
| 75 | u64 performance = 0; | 74 | u64 performance = 0; |
| 76 | std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16)); | 75 | std::vector<opus_int16> samples(ctx.GetWriteBufferSize() / sizeof(opus_int16)); |
| 77 | if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples, | 76 | if (!Decoder_DecodeInterleaved(consumed, sample_count, ctx.ReadBuffer(), samples, |
| 78 | performance)) { | 77 | &performance)) { |
| 79 | LOG_ERROR(Audio, "Failed to decode opus data"); | 78 | LOG_ERROR(Audio, "Failed to decode opus data"); |
| 80 | IPC::ResponseBuilder rb{ctx, 2}; | 79 | IPC::ResponseBuilder rb{ctx, 2}; |
| 81 | // TODO(ogniK): Use correct error code | 80 | // TODO(ogniK): Use correct error code |
| @@ -90,10 +89,8 @@ private: | |||
| 90 | ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16)); | 89 | ctx.WriteBuffer(samples.data(), samples.size() * sizeof(s16)); |
| 91 | } | 90 | } |
| 92 | 91 | ||
| 93 | bool Decoder_DecodeInterleaved( | 92 | bool Decoder_DecodeInterleaved(u32& consumed, u32& sample_count, const std::vector<u8>& input, |
| 94 | u32& consumed, u32& sample_count, const std::vector<u8>& input, | 93 | std::vector<opus_int16>& output, u64* out_performance_time) { |
| 95 | std::vector<opus_int16>& output, | ||
| 96 | std::optional<std::reference_wrapper<u64>> performance_time = std::nullopt) { | ||
| 97 | const auto start_time = std::chrono::high_resolution_clock::now(); | 94 | const auto start_time = std::chrono::high_resolution_clock::now(); |
| 98 | const std::size_t raw_output_sz = output.size() * sizeof(opus_int16); | 95 | const std::size_t raw_output_sz = output.size() * sizeof(opus_int16); |
| 99 | if (sizeof(OpusHeader) > input.size()) { | 96 | if (sizeof(OpusHeader) > input.size()) { |
| @@ -136,8 +133,8 @@ private: | |||
| 136 | const auto end_time = std::chrono::high_resolution_clock::now() - start_time; | 133 | const auto end_time = std::chrono::high_resolution_clock::now() - start_time; |
| 137 | sample_count = out_sample_count; | 134 | sample_count = out_sample_count; |
| 138 | consumed = static_cast<u32>(sizeof(OpusHeader) + hdr.sz); | 135 | consumed = static_cast<u32>(sizeof(OpusHeader) + hdr.sz); |
| 139 | if (performance_time.has_value()) { | 136 | if (out_performance_time != nullptr) { |
| 140 | performance_time->get() = | 137 | *out_performance_time = |
| 141 | std::chrono::duration_cast<std::chrono::milliseconds>(end_time).count(); | 138 | std::chrono::duration_cast<std::chrono::milliseconds>(end_time).count(); |
| 142 | } | 139 | } |
| 143 | 140 | ||