From c4e7ec7a996d49517852d1f5d46160cfc2bd6032 Mon Sep 17 00:00:00 2001 From: David Marcec Date: Wed, 22 Apr 2020 13:12:58 +1000 Subject: pass by const ref instead --- src/audio_core/audio_renderer.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/audio_core/audio_renderer.cpp b/src/audio_core/audio_renderer.cpp index f54ce48c5..fc6e70f6b 100644 --- a/src/audio_core/audio_renderer.cpp +++ b/src/audio_core/audio_renderer.cpp @@ -17,7 +17,7 @@ namespace AudioCore { constexpr u32 STREAM_SAMPLE_RATE{48000}; constexpr u32 STREAM_NUM_CHANNELS{2}; - +using VoiceChannelHolder = std::array; class AudioRenderer::VoiceState { public: bool IsPlaying() const { @@ -38,10 +38,9 @@ public: void SetWaveIndex(std::size_t index); std::vector DequeueSamples(std::size_t sample_count, Core::Memory::Memory& memory, - std::array voice_resources); + const VoiceChannelHolder& voice_resources); void UpdateState(); - void RefreshBuffer(Core::Memory::Memory& memory, - std::array voice_resources); + void RefreshBuffer(Core::Memory::Memory& memory, const VoiceChannelHolder& voice_resources); private: bool is_in_use{}; @@ -230,7 +229,7 @@ void AudioRenderer::VoiceState::SetWaveIndex(std::size_t index) { std::vector AudioRenderer::VoiceState::DequeueSamples( std::size_t sample_count, Core::Memory::Memory& memory, - std::array voice_resources) { + const VoiceChannelHolder& voice_resources) { if (!IsPlaying()) { return {}; } @@ -280,8 +279,8 @@ void AudioRenderer::VoiceState::UpdateState() { is_in_use = info.is_in_use; } -void AudioRenderer::VoiceState::RefreshBuffer( - Core::Memory::Memory& memory, std::array voice_resources) { +void AudioRenderer::VoiceState::RefreshBuffer(Core::Memory::Memory& memory, + const VoiceChannelHolder& voice_resources) { const auto wave_buffer_address = info.wave_buffer[wave_index].buffer_addr; const auto wave_buffer_size = info.wave_buffer[wave_index].buffer_sz; std::vector new_samples(wave_buffer_size / sizeof(s16)); @@ -420,7 +419,7 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) { if (!voice.IsPlaying()) { continue; } - std::array resources{}; + VoiceChannelHolder resources{}; for (u32 channel = 0; channel < voice.GetInfo().channel_count; channel++) { const auto channel_resource_id = voice.GetInfo().voice_channel_resource_ids[channel]; resources[channel] = &voice_resources[channel_resource_id]; -- cgit v1.2.3