summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-27 17:43:00 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-27 17:43:00 +0200
commitb805f112c21a1e5bae8d66caa1d640ad2d5e6f5f (patch)
treedb5130eb96319ffc904907a7a353d9baf4b549d7 /Servers
parent426248098c18bd44b50252b066a0c672c62eba69 (diff)
downloadserenity-b805f112c21a1e5bae8d66caa1d640ad2d5e6f5f.zip
AudioServer: Avoid two heap allocations per mixing iteration.
Diffstat (limited to 'Servers')
-rw-r--r--Servers/AudioServer/ASMixer.cpp5
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) {