From bdb866af1d28d47c36ec84fbcde53f64f09c3fd1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 13 Sep 2022 13:28:50 -0400 Subject: compressor: Remove unneeded casts in ApplyCompressorEffect Same behavior, but also silences a -Wcast-qual warning, since the second cast casts away const. --- src/audio_core/renderer/command/effect/compressor.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/audio_core/renderer/command/effect/compressor.cpp b/src/audio_core/renderer/command/effect/compressor.cpp index 2ebc140f1..f9bba9f39 100644 --- a/src/audio_core/renderer/command/effect/compressor.cpp +++ b/src/audio_core/renderer/command/effect/compressor.cpp @@ -103,8 +103,7 @@ static void ApplyCompressorEffect(CompressorInfo::ParameterVersion2& params, } else { for (s16 channel = 0; channel < params.channel_count; channel++) { if (params.inputs[channel] != params.outputs[channel]) { - std::memcpy((char*)output_buffers[channel].data(), - (char*)input_buffers[channel].data(), + std::memcpy(output_buffers[channel].data(), input_buffers[channel].data(), output_buffers[channel].size_bytes()); } } -- cgit v1.2.3 From fd876f200f1c09cd4d840c1f3401390e00322b15 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 13 Sep 2022 13:33:38 -0400 Subject: compressor: Mark params parameters as const These functions don't modify the parameters. --- src/audio_core/renderer/command/effect/compressor.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/audio_core/renderer/command/effect/compressor.cpp b/src/audio_core/renderer/command/effect/compressor.cpp index f9bba9f39..8c1b07609 100644 --- a/src/audio_core/renderer/command/effect/compressor.cpp +++ b/src/audio_core/renderer/command/effect/compressor.cpp @@ -11,7 +11,7 @@ namespace AudioCore::AudioRenderer { -static void SetCompressorEffectParameter(CompressorInfo::ParameterVersion2& params, +static void SetCompressorEffectParameter(const CompressorInfo::ParameterVersion2& params, CompressorInfo::State& state) { const auto ratio{1.0f / params.compressor_ratio}; auto makeup_gain{0.0f}; @@ -31,7 +31,7 @@ static void SetCompressorEffectParameter(CompressorInfo::ParameterVersion2& para state.unk_20 = c; } -static void InitializeCompressorEffect(CompressorInfo::ParameterVersion2& params, +static void InitializeCompressorEffect(const CompressorInfo::ParameterVersion2& params, CompressorInfo::State& state) { std::memset(&state, 0, sizeof(CompressorInfo::State)); @@ -42,7 +42,7 @@ static void InitializeCompressorEffect(CompressorInfo::ParameterVersion2& params SetCompressorEffectParameter(params, state); } -static void ApplyCompressorEffect(CompressorInfo::ParameterVersion2& params, +static void ApplyCompressorEffect(const CompressorInfo::ParameterVersion2& params, CompressorInfo::State& state, bool enabled, std::vector> input_buffers, std::vector> output_buffers, u32 sample_count) { -- cgit v1.2.3 From f08046f4d7f86207bac547263113f5ba0ceab9ff Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 13 Sep 2022 13:34:56 -0400 Subject: compressor: Simplify memset in InitializeCompressorEffect Provides equivalent behavior while being significantly smaller. --- src/audio_core/renderer/command/effect/compressor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/audio_core/renderer/command/effect/compressor.cpp b/src/audio_core/renderer/command/effect/compressor.cpp index 8c1b07609..7229618e8 100644 --- a/src/audio_core/renderer/command/effect/compressor.cpp +++ b/src/audio_core/renderer/command/effect/compressor.cpp @@ -33,7 +33,7 @@ static void SetCompressorEffectParameter(const CompressorInfo::ParameterVersion2 static void InitializeCompressorEffect(const CompressorInfo::ParameterVersion2& params, CompressorInfo::State& state) { - std::memset(&state, 0, sizeof(CompressorInfo::State)); + state = {}; state.unk_00 = 0; state.unk_04 = 1.0f; -- cgit v1.2.3