From 45e13b03f372230dbf780f3fa87dd88f388af605 Mon Sep 17 00:00:00 2001 From: arades79 Date: Sat, 11 Feb 2023 13:28:03 -0500 Subject: add static lifetime to constexpr values to force compile time evaluation where possible Signed-off-by: arades79 --- src/audio_core/sink/sink_stream.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/audio_core/sink/sink_stream.cpp') diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 06c2a876e..fa3cee3ea 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -24,8 +24,8 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector& samples) { return; } - constexpr s32 min{std::numeric_limits::min()}; - constexpr s32 max{std::numeric_limits::max()}; + constexpr static s32 min{std::numeric_limits::min()}; + constexpr static s32 max{std::numeric_limits::max()}; auto yuzu_volume{Settings::Volume()}; if (yuzu_volume > 1.0f) { @@ -35,7 +35,7 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector& samples) { if (system_channels == 6 && device_channels == 2) { // We're given 6 channels, but our device only outputs 2, so downmix. - constexpr std::array down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f}; + constexpr static std::array down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f}; for (u32 read_index = 0, write_index = 0; read_index < samples.size(); read_index += system_channels, write_index += device_channels) { @@ -106,8 +106,8 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector& samples) { } std::vector SinkStream::ReleaseBuffer(u64 num_samples) { - constexpr s32 min = std::numeric_limits::min(); - constexpr s32 max = std::numeric_limits::max(); + constexpr static s32 min = std::numeric_limits::min(); + constexpr static s32 max = std::numeric_limits::max(); auto samples{samples_buffer.Pop(num_samples)}; @@ -202,7 +202,7 @@ void SinkStream::ProcessAudioOutAndRender(std::span output_buffer, std::siz // If we're paused or going to shut down, we don't want to consume buffers as coretiming is // paused and we'll desync, so just play silence. if (system.IsPaused() || system.IsShuttingDown()) { - constexpr std::array silence{}; + constexpr static std::array silence{}; for (size_t i = frames_written; i < num_frames; i++) { std::memcpy(&output_buffer[i * frame_size], &silence[0], frame_size_bytes); } -- cgit v1.2.3 From 683019878fc939b418a65e1c5d84b066596d7655 Mon Sep 17 00:00:00 2001 From: arades79 Date: Tue, 14 Feb 2023 11:13:47 -0500 Subject: remove static from pointer sized or smaller types for aesthetics, change constexpr static to static constexpr for consistency Signed-off-by: arades79 --- src/audio_core/sink/sink_stream.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/audio_core/sink/sink_stream.cpp') diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index fa3cee3ea..2fb5f9758 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp @@ -24,8 +24,8 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector& samples) { return; } - constexpr static s32 min{std::numeric_limits::min()}; - constexpr static s32 max{std::numeric_limits::max()}; + constexpr s32 min{std::numeric_limits::min()}; + constexpr s32 max{std::numeric_limits::max()}; auto yuzu_volume{Settings::Volume()}; if (yuzu_volume > 1.0f) { @@ -35,7 +35,7 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector& samples) { if (system_channels == 6 && device_channels == 2) { // We're given 6 channels, but our device only outputs 2, so downmix. - constexpr static std::array down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f}; + static constexpr std::array down_mix_coeff{1.0f, 0.707f, 0.251f, 0.707f}; for (u32 read_index = 0, write_index = 0; read_index < samples.size(); read_index += system_channels, write_index += device_channels) { @@ -106,8 +106,8 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::vector& samples) { } std::vector SinkStream::ReleaseBuffer(u64 num_samples) { - constexpr static s32 min = std::numeric_limits::min(); - constexpr static s32 max = std::numeric_limits::max(); + constexpr s32 min = std::numeric_limits::min(); + constexpr s32 max = std::numeric_limits::max(); auto samples{samples_buffer.Pop(num_samples)}; @@ -202,7 +202,7 @@ void SinkStream::ProcessAudioOutAndRender(std::span output_buffer, std::siz // If we're paused or going to shut down, we don't want to consume buffers as coretiming is // paused and we'll desync, so just play silence. if (system.IsPaused() || system.IsShuttingDown()) { - constexpr static std::array silence{}; + static constexpr std::array silence{}; for (size_t i = frames_written; i < num_frames; i++) { std::memcpy(&output_buffer[i * frame_size], &silence[0], frame_size_bytes); } -- cgit v1.2.3