diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 17:43:00 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-27 17:43:00 +0200 |
commit | b805f112c21a1e5bae8d66caa1d640ad2d5e6f5f (patch) | |
tree | db5130eb96319ffc904907a7a353d9baf4b549d7 /Servers | |
parent | 426248098c18bd44b50252b066a0c672c62eba69 (diff) | |
download | serenity-b805f112c21a1e5bae8d66caa1d640ad2d5e6f5f.zip |
AudioServer: Avoid two heap allocations per mixing iteration.
Diffstat (limited to 'Servers')
-rw-r--r-- | Servers/AudioServer/ASMixer.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Servers/AudioServer/ASMixer.cpp b/Servers/AudioServer/ASMixer.cpp index 472d126cec..81d3180016 100644 --- a/Servers/AudioServer/ASMixer.cpp +++ b/Servers/AudioServer/ASMixer.cpp @@ -61,7 +61,7 @@ void ASMixer::mix() max_size = min(1023, max_size); - Vector<ASample> mixed_buffer; + Vector<ASample, 1024> mixed_buffer; mixed_buffer.resize(max_size); // Mix the buffers together into the output @@ -91,7 +91,8 @@ void ASMixer::mix() // max_size is 0 indexed, so add 1. const int output_buffer_byte_size = (max_size + 1) * 2 * 2; ASSERT(output_buffer_byte_size == 4096); - ByteBuffer buffer(ByteBuffer::create_uninitialized(output_buffer_byte_size)); + u8 raw_buffer[4096]; + auto buffer = ByteBuffer::wrap(raw_buffer, sizeof(raw_buffer)); BufferStream stream(buffer); for (int i = 0; i < mixed_buffer.size(); ++i) { |