pass by const ref instead

master
David Marcec 2020-04-22 13:12:58 +07:00 committed by bunnei
parent 9de860a419
commit c4e7ec7a99
1 changed files with 7 additions and 8 deletions

@ -17,7 +17,7 @@ namespace AudioCore {
constexpr u32 STREAM_SAMPLE_RATE{48000}; constexpr u32 STREAM_SAMPLE_RATE{48000};
constexpr u32 STREAM_NUM_CHANNELS{2}; constexpr u32 STREAM_NUM_CHANNELS{2};
using VoiceChannelHolder = std::array<VoiceResourceInformation*, 6>;
class AudioRenderer::VoiceState { class AudioRenderer::VoiceState {
public: public:
bool IsPlaying() const { bool IsPlaying() const {
@ -38,10 +38,9 @@ public:
void SetWaveIndex(std::size_t index); void SetWaveIndex(std::size_t index);
std::vector<s16> DequeueSamples(std::size_t sample_count, Core::Memory::Memory& memory, std::vector<s16> DequeueSamples(std::size_t sample_count, Core::Memory::Memory& memory,
std::array<VoiceResourceInformation*, 6> voice_resources); const VoiceChannelHolder& voice_resources);
void UpdateState(); void UpdateState();
void RefreshBuffer(Core::Memory::Memory& memory, void RefreshBuffer(Core::Memory::Memory& memory, const VoiceChannelHolder& voice_resources);
std::array<VoiceResourceInformation*, 6> voice_resources);
private: private:
bool is_in_use{}; bool is_in_use{};
@ -230,7 +229,7 @@ void AudioRenderer::VoiceState::SetWaveIndex(std::size_t index) {
std::vector<s16> AudioRenderer::VoiceState::DequeueSamples( std::vector<s16> AudioRenderer::VoiceState::DequeueSamples(
std::size_t sample_count, Core::Memory::Memory& memory, std::size_t sample_count, Core::Memory::Memory& memory,
std::array<VoiceResourceInformation*, 6> voice_resources) { const VoiceChannelHolder& voice_resources) {
if (!IsPlaying()) { if (!IsPlaying()) {
return {}; return {};
} }
@ -280,8 +279,8 @@ void AudioRenderer::VoiceState::UpdateState() {
is_in_use = info.is_in_use; is_in_use = info.is_in_use;
} }
void AudioRenderer::VoiceState::RefreshBuffer( void AudioRenderer::VoiceState::RefreshBuffer(Core::Memory::Memory& memory,
Core::Memory::Memory& memory, std::array<VoiceResourceInformation*, 6> voice_resources) { const VoiceChannelHolder& voice_resources) {
const auto wave_buffer_address = info.wave_buffer[wave_index].buffer_addr; const auto wave_buffer_address = info.wave_buffer[wave_index].buffer_addr;
const auto wave_buffer_size = info.wave_buffer[wave_index].buffer_sz; const auto wave_buffer_size = info.wave_buffer[wave_index].buffer_sz;
std::vector<s16> new_samples(wave_buffer_size / sizeof(s16)); std::vector<s16> new_samples(wave_buffer_size / sizeof(s16));
@ -420,7 +419,7 @@ void AudioRenderer::QueueMixedBuffer(Buffer::Tag tag) {
if (!voice.IsPlaying()) { if (!voice.IsPlaying()) {
continue; continue;
} }
std::array<VoiceResourceInformation*, 6> resources{}; VoiceChannelHolder resources{};
for (u32 channel = 0; channel < voice.GetInfo().channel_count; channel++) { for (u32 channel = 0; channel < voice.GetInfo().channel_count; channel++) {
const auto channel_resource_id = voice.GetInfo().voice_channel_resource_ids[channel]; const auto channel_resource_id = voice.GetInfo().voice_channel_resource_ids[channel];
resources[channel] = &voice_resources[channel_resource_id]; resources[channel] = &voice_resources[channel_resource_id];