diff options
| -rw-r--r-- | src/audio_core/audio_renderer.cpp | 4 | ||||
| -rw-r--r-- | src/audio_core/sink_context.cpp | 8 | ||||
| -rw-r--r-- | src/audio_core/sink_context.h | 10 | ||||
| -rw-r--r-- | src/audio_core/stream.cpp | 1 |
4 files changed, 13 insertions, 10 deletions
diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp index 03a133640..e1ded84e0 100644 --- a/src/audio_core/audio_renderer.cpp +++ b/src/audio_core/audio_renderer.cpp | |||
| @@ -17,8 +17,8 @@ | |||
| 17 | 17 | ||
| 18 | namespace { | 18 | namespace { |
| 19 | [[nodiscard]] static constexpr s16 ClampToS16(s32 value) { | 19 | [[nodiscard]] static constexpr s16 ClampToS16(s32 value) { |
| 20 | return static_cast<s16>(std::clamp(value, static_cast<s32>(std::numeric_limits<s16>::min()), | 20 | return static_cast<s16>(std::clamp(value, s32{std::numeric_limits<s16>::min()}, |
| 21 | static_cast<s32>(std::numeric_limits<s16>::max()))); | 21 | s32{std::numeric_limits<s16>::max()})); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | [[nodiscard]] static constexpr s16 Mix2To1(s16 l_channel, s16 r_channel) { | 24 | [[nodiscard]] static constexpr s16 Mix2To1(s16 l_channel, s16 r_channel) { |
diff --git a/src/audio_core/sink_context.cpp b/src/audio_core/sink_context.cpp index cdb47ba81..b29b47890 100644 --- a/src/audio_core/sink_context.cpp +++ b/src/audio_core/sink_context.cpp | |||
| @@ -15,8 +15,8 @@ std::size_t SinkContext::GetCount() const { | |||
| 15 | void SinkContext::UpdateMainSink(const SinkInfo::InParams& in) { | 15 | void SinkContext::UpdateMainSink(const SinkInfo::InParams& in) { |
| 16 | ASSERT(in.type == SinkTypes::Device); | 16 | ASSERT(in.type == SinkTypes::Device); |
| 17 | 17 | ||
| 18 | downmix = in.device.down_matrix_enabled; | 18 | has_downmix_coefs = in.device.down_matrix_enabled; |
| 19 | if (downmix) { | 19 | if (has_downmix_coefs) { |
| 20 | downmix_coefficients = in.device.down_matrix_coef; | 20 | downmix_coefficients = in.device.down_matrix_coef; |
| 21 | } | 21 | } |
| 22 | in_use = in.in_use; | 22 | in_use = in.in_use; |
| @@ -35,10 +35,10 @@ std::vector<u8> SinkContext::OutputBuffers() const { | |||
| 35 | } | 35 | } |
| 36 | 36 | ||
| 37 | bool SinkContext::HasDownMixingCoefficients() const { | 37 | bool SinkContext::HasDownMixingCoefficients() const { |
| 38 | return downmix; | 38 | return has_downmix_coefs; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | const std::array<float_le, 4>& SinkContext::GetDownmixCoefficients() const { | 41 | const DownmixCoefficients& SinkContext::GetDownmixCoefficients() const { |
| 42 | return downmix_coefficients; | 42 | return downmix_coefficients; |
| 43 | } | 43 | } |
| 44 | 44 | ||
diff --git a/src/audio_core/sink_context.h b/src/audio_core/sink_context.h index 5a757a4ef..e2e7880b7 100644 --- a/src/audio_core/sink_context.h +++ b/src/audio_core/sink_context.h | |||
| @@ -11,6 +11,8 @@ | |||
| 11 | 11 | ||
| 12 | namespace AudioCore { | 12 | namespace AudioCore { |
| 13 | 13 | ||
| 14 | using DownmixCoefficients = std::array<float_le, 4>; | ||
| 15 | |||
| 14 | enum class SinkTypes : u8 { | 16 | enum class SinkTypes : u8 { |
| 15 | Invalid = 0, | 17 | Invalid = 0, |
| 16 | Device = 1, | 18 | Device = 1, |
| @@ -50,7 +52,7 @@ public: | |||
| 50 | std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> input; | 52 | std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> input; |
| 51 | INSERT_UNION_PADDING_BYTES(1); | 53 | INSERT_UNION_PADDING_BYTES(1); |
| 52 | bool down_matrix_enabled; | 54 | bool down_matrix_enabled; |
| 53 | std::array<float_le, 4> down_matrix_coef; | 55 | DownmixCoefficients down_matrix_coef; |
| 54 | }; | 56 | }; |
| 55 | static_assert(sizeof(SinkInfo::DeviceIn) == 0x11c, "SinkInfo::DeviceIn is an invalid size"); | 57 | static_assert(sizeof(SinkInfo::DeviceIn) == 0x11c, "SinkInfo::DeviceIn is an invalid size"); |
| 56 | 58 | ||
| @@ -81,14 +83,14 @@ public: | |||
| 81 | [[nodiscard]] std::vector<u8> OutputBuffers() const; | 83 | [[nodiscard]] std::vector<u8> OutputBuffers() const; |
| 82 | 84 | ||
| 83 | [[nodiscard]] bool HasDownMixingCoefficients() const; | 85 | [[nodiscard]] bool HasDownMixingCoefficients() const; |
| 84 | [[nodiscard]] const std::array<float_le, 4>& GetDownmixCoefficients() const; | 86 | [[nodiscard]] const DownmixCoefficients& GetDownmixCoefficients() const; |
| 85 | 87 | ||
| 86 | private: | 88 | private: |
| 87 | bool in_use{false}; | 89 | bool in_use{false}; |
| 88 | s32 use_count{}; | 90 | s32 use_count{}; |
| 89 | std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> buffers{}; | 91 | std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> buffers{}; |
| 90 | std::size_t sink_count{}; | 92 | std::size_t sink_count{}; |
| 91 | bool downmix{false}; | 93 | bool has_downmix_coefs{false}; |
| 92 | std::array<float_le, 4> downmix_coefficients{}; | 94 | DownmixCoefficients downmix_coefficients{}; |
| 93 | }; | 95 | }; |
| 94 | } // namespace AudioCore | 96 | } // namespace AudioCore |
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index 3f11b84ae..41bc2f4d6 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp | |||
| @@ -138,6 +138,7 @@ std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers(std::size_t max_count) | |||
| 138 | 138 | ||
| 139 | std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers() { | 139 | std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers() { |
| 140 | std::vector<Buffer::Tag> tags; | 140 | std::vector<Buffer::Tag> tags; |
| 141 | tags.reserve(released_buffers.size()); | ||
| 141 | while (!released_buffers.empty()) { | 142 | while (!released_buffers.empty()) { |
| 142 | tags.push_back(released_buffers.front()->GetTag()); | 143 | tags.push_back(released_buffers.front()->GetTag()); |
| 143 | released_buffers.pop(); | 144 | released_buffers.pop(); |