Addressed changes

This commit is contained in:
Chloe Marcec 2020-11-17 15:40:19 +11:00
parent 9a4beac95a
commit 908d3c5679
4 changed files with 13 additions and 10 deletions

View File

@ -17,8 +17,8 @@
namespace { namespace {
[[nodiscard]] static constexpr s16 ClampToS16(s32 value) { [[nodiscard]] static constexpr s16 ClampToS16(s32 value) {
return static_cast<s16>(std::clamp(value, static_cast<s32>(std::numeric_limits<s16>::min()), return static_cast<s16>(std::clamp(value, s32{std::numeric_limits<s16>::min()},
static_cast<s32>(std::numeric_limits<s16>::max()))); s32{std::numeric_limits<s16>::max()}));
} }
[[nodiscard]] static constexpr s16 Mix2To1(s16 l_channel, s16 r_channel) { [[nodiscard]] static constexpr s16 Mix2To1(s16 l_channel, s16 r_channel) {

View File

@ -15,8 +15,8 @@ std::size_t SinkContext::GetCount() const {
void SinkContext::UpdateMainSink(const SinkInfo::InParams& in) { void SinkContext::UpdateMainSink(const SinkInfo::InParams& in) {
ASSERT(in.type == SinkTypes::Device); ASSERT(in.type == SinkTypes::Device);
downmix = in.device.down_matrix_enabled; has_downmix_coefs = in.device.down_matrix_enabled;
if (downmix) { if (has_downmix_coefs) {
downmix_coefficients = in.device.down_matrix_coef; downmix_coefficients = in.device.down_matrix_coef;
} }
in_use = in.in_use; in_use = in.in_use;
@ -35,10 +35,10 @@ std::vector<u8> SinkContext::OutputBuffers() const {
} }
bool SinkContext::HasDownMixingCoefficients() const { bool SinkContext::HasDownMixingCoefficients() const {
return downmix; return has_downmix_coefs;
} }
const std::array<float_le, 4>& SinkContext::GetDownmixCoefficients() const { const DownmixCoefficients& SinkContext::GetDownmixCoefficients() const {
return downmix_coefficients; return downmix_coefficients;
} }

View File

@ -11,6 +11,8 @@
namespace AudioCore { namespace AudioCore {
using DownmixCoefficients = std::array<float_le, 4>;
enum class SinkTypes : u8 { enum class SinkTypes : u8 {
Invalid = 0, Invalid = 0,
Device = 1, Device = 1,
@ -50,7 +52,7 @@ public:
std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> input; std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> input;
INSERT_UNION_PADDING_BYTES(1); INSERT_UNION_PADDING_BYTES(1);
bool down_matrix_enabled; bool down_matrix_enabled;
std::array<float_le, 4> down_matrix_coef; DownmixCoefficients down_matrix_coef;
}; };
static_assert(sizeof(SinkInfo::DeviceIn) == 0x11c, "SinkInfo::DeviceIn is an invalid size"); static_assert(sizeof(SinkInfo::DeviceIn) == 0x11c, "SinkInfo::DeviceIn is an invalid size");
@ -81,14 +83,14 @@ public:
[[nodiscard]] std::vector<u8> OutputBuffers() const; [[nodiscard]] std::vector<u8> OutputBuffers() const;
[[nodiscard]] bool HasDownMixingCoefficients() const; [[nodiscard]] bool HasDownMixingCoefficients() const;
[[nodiscard]] const std::array<float_le, 4>& GetDownmixCoefficients() const; [[nodiscard]] const DownmixCoefficients& GetDownmixCoefficients() const;
private: private:
bool in_use{false}; bool in_use{false};
s32 use_count{}; s32 use_count{};
std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> buffers{}; std::array<u8, AudioCommon::MAX_CHANNEL_COUNT> buffers{};
std::size_t sink_count{}; std::size_t sink_count{};
bool downmix{false}; bool has_downmix_coefs{false};
std::array<float_le, 4> downmix_coefficients{}; DownmixCoefficients downmix_coefficients{};
}; };
} // namespace AudioCore } // namespace AudioCore

View File

@ -138,6 +138,7 @@ std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers(std::size_t max_count)
std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers() { std::vector<Buffer::Tag> Stream::GetTagsAndReleaseBuffers() {
std::vector<Buffer::Tag> tags; std::vector<Buffer::Tag> tags;
tags.reserve(released_buffers.size());
while (!released_buffers.empty()) { while (!released_buffers.empty()) {
tags.push_back(released_buffers.front()->GetTag()); tags.push_back(released_buffers.front()->GetTag());
released_buffers.pop(); released_buffers.pop();