diff options
| author | 2020-04-22 13:12:58 +1000 | |
|---|---|---|
| committer | 2020-05-11 12:56:15 -0400 | |
| commit | c4e7ec7a996d49517852d1f5d46160cfc2bd6032 (patch) | |
| tree | dcf8868263f8c3242c32950b9d55970bf2547f4c /src/audio_core/audio_renderer.cpp | |
| parent | audio_renderer: Better voice mixing and 6 channel downmixing (diff) | |
| download | yuzu-c4e7ec7a996d49517852d1f5d46160cfc2bd6032.tar.gz yuzu-c4e7ec7a996d49517852d1f5d46160cfc2bd6032.tar.xz yuzu-c4e7ec7a996d49517852d1f5d46160cfc2bd6032.zip | |
pass by const ref instead
Diffstat (limited to 'src/audio_core/audio_renderer.cpp')
| -rw-r--r-- | src/audio_core/audio_renderer.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
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 { | |||
| 17 | 17 | ||
| 18 | constexpr u32 STREAM_SAMPLE_RATE{48000}; | 18 | constexpr u32 STREAM_SAMPLE_RATE{48000}; |
| 19 | constexpr u32 STREAM_NUM_CHANNELS{2}; | 19 | constexpr u32 STREAM_NUM_CHANNELS{2}; |
| 20 | 20 | using VoiceChannelHolder = std::array<VoiceResourceInformation*, 6>; | |
| 21 | class AudioRenderer::VoiceState { | 21 | class AudioRenderer::VoiceState { |
| 22 | public: | 22 | public: |
| 23 | bool IsPlaying() const { | 23 | bool IsPlaying() const { |
| @@ -38,10 +38,9 @@ public: | |||
| 38 | 38 | ||
| 39 | void SetWaveIndex(std::size_t index); | 39 | void SetWaveIndex(std::size_t index); |
| 40 | std::vector<s16> DequeueSamples(std::size_t sample_count, Core::Memory::Memory& memory, | 40 | std::vector<s16> DequeueSamples(std::size_t sample_count, Core::Memory::Memory& memory, |
| 41 | std::array<VoiceResourceInformation*, 6> voice_resources); | 41 | const VoiceChannelHolder& voice_resources); |
| 42 | void UpdateState(); | 42 | void UpdateState(); |
| 43 | void RefreshBuffer(Core::Memory::Memory& memory, | 43 | void RefreshBuffer(Core::Memory::Memory& memory, const VoiceChannelHolder& voice_resources); |
| 44 | std::array<VoiceResourceInformation*, 6> voice_resources); | ||
| 45 | 44 | ||
| 46 | private: | 45 | private: |
| 47 | bool is_in_use{}; | 46 | bool is_in_use{}; |
| @@ -230,7 +229,7 @@ void AudioRenderer::VoiceState::SetWaveIndex(std::size_t index) { | |||
| 230 | 229 | ||
| 231 | std::vector<s16> AudioRenderer::VoiceState::DequeueSamples( | 230 | std::vector<s16> AudioRenderer::VoiceState::DequeueSamples( |
| 232 | std::size_t sample_count, Core::Memory::Memory& memory, | 231 | std::size_t sample_count, Core::Memory::Memory& memory, |
| 233 | std::array<VoiceResourceInformation*, 6> voice_resources) { | 232 | const VoiceChannelHolder& voice_resources) { |
| 234 | if (!IsPlaying()) { | 233 | if (!IsPlaying()) { |
| 235 | return {}; | 234 | return {}; |
| 236 | } | 235 | } |
| @@ -280,8 +279,8 @@ void AudioRenderer::VoiceState::UpdateState() { | |||
| 280 | is_in_use = info.is_in_use; | 279 | is_in_use = info.is_in_use; |
| 281 | } | 280 | } |
| 282 | 281 | ||
| 283 | void AudioRenderer::VoiceState::RefreshBuffer( | 282 | void AudioRenderer::VoiceState::RefreshBuffer(Core::Memory::Memory& memory, |
| 284 | Core::Memory::Memory& memory, std::array<VoiceResourceInformation*, 6> voice_resources) { | 283 | const VoiceChannelHolder& voice_resources) { |
| 285 | const auto wave_buffer_address = info.wave_buffer[wave_index].buffer_addr; | 284 | const auto wave_buffer_address = info.wave_buffer[wave_index].buffer_addr; |
| 286 | const auto wave_buffer_size = info.wave_buffer[wave_index].buffer_sz; | 285 | const auto wave_buffer_size = info.wave_buffer[wave_index].buffer_sz; |
| 287 | std::vector<s16> new_samples(wave_buffer_size / sizeof(s16)); | 286 | std::vector<s16> new_samples(wave_buffer_size / sizeof(s16)); |
| @@ -420,7 +419,7 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) { | |||
| 420 | if (!voice.IsPlaying()) { | 419 | if (!voice.IsPlaying()) { |
| 421 | continue; | 420 | continue; |
| 422 | } | 421 | } |
| 423 | std::array<VoiceResourceInformation*, 6> resources{}; | 422 | VoiceChannelHolder resources{}; |
| 424 | for (u32 channel = 0; channel < voice.GetInfo().channel_count; channel++) { | 423 | for (u32 channel = 0; channel < voice.GetInfo().channel_count; channel++) { |
| 425 | const auto channel_resource_id = voice.GetInfo().voice_channel_resource_ids[channel]; | 424 | const auto channel_resource_id = voice.GetInfo().voice_channel_resource_ids[channel]; |
| 426 | resources[channel] = &voice_resources[channel_resource_id]; | 425 | resources[channel] = &voice_resources[channel_resource_id]; |