diff options
| author | bunnei <bunneidev@gmail.com> | 2023-06-22 21:53:07 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-06-22 21:53:07 -0700 |
| commit | 2fc5dedf6996d4a5c93ddf1ccd67a6963e4827e8 (patch) | |
| tree | d82f2cf4f7a5e9773616846c095a941b282a84f6 /src/audio_core/renderer/command/sink | |
| parent | 3f3e4efb30de021fed52badc34808008276db9e7 (diff) | |
| parent | 5da70f719703084482933e103e561cc98163f370 (diff) | |
Merge pull request #10457 from Kelebek1/optimise
Remove memory allocations in some hot paths
Diffstat (limited to 'src/audio_core/renderer/command/sink')
| -rw-r--r-- | src/audio_core/renderer/command/sink/circular_buffer.cpp | 4 | ||||
| -rw-r--r-- | src/audio_core/renderer/command/sink/device.cpp | 5 |
2 files changed, 4 insertions, 5 deletions
diff --git a/src/audio_core/renderer/command/sink/circular_buffer.cpp b/src/audio_core/renderer/command/sink/circular_buffer.cpp index ded5afc94..e2ce59792 100644 --- a/src/audio_core/renderer/command/sink/circular_buffer.cpp +++ b/src/audio_core/renderer/command/sink/circular_buffer.cpp @@ -24,7 +24,7 @@ void CircularBufferSinkCommand::Process(const ADSP::CommandListProcessor& proces constexpr s32 min{std::numeric_limits<s16>::min()}; constexpr s32 max{std::numeric_limits<s16>::max()}; - std::vector<s16> output(processor.sample_count); + std::array<s16, TargetSampleCount * MaxChannels> output{}; for (u32 channel = 0; channel < input_count; channel++) { auto input{processor.mix_buffers.subspan(inputs[channel] * processor.sample_count, processor.sample_count)}; @@ -33,7 +33,7 @@ void CircularBufferSinkCommand::Process(const ADSP::CommandListProcessor& proces } processor.memory->WriteBlockUnsafe(address + pos, output.data(), - output.size() * sizeof(s16)); + processor.sample_count * sizeof(s16)); pos += static_cast<u32>(processor.sample_count * sizeof(s16)); if (pos >= size) { pos = 0; diff --git a/src/audio_core/renderer/command/sink/device.cpp b/src/audio_core/renderer/command/sink/device.cpp index e88372a75..5f74dd7ad 100644 --- a/src/audio_core/renderer/command/sink/device.cpp +++ b/src/audio_core/renderer/command/sink/device.cpp @@ -33,8 +33,7 @@ void DeviceSinkCommand::Process(const ADSP::CommandListProcessor& processor) { .consumed{false}, }; - std::vector<s16> samples(out_buffer.frames * input_count); - + std::array<s16, TargetSampleCount * MaxChannels> samples{}; for (u32 channel = 0; channel < input_count; channel++) { const auto offset{inputs[channel] * out_buffer.frames}; @@ -45,7 +44,7 @@ void DeviceSinkCommand::Process(const ADSP::CommandListProcessor& processor) { } out_buffer.tag = reinterpret_cast<u64>(samples.data()); - stream->AppendBuffer(out_buffer, samples); + stream->AppendBuffer(out_buffer, {samples.data(), out_buffer.frames * input_count}); if (stream->IsPaused()) { stream->Start(); |
