mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-23 08:00:20 +00:00
AudioServer: Avoid two heap allocations per mixing iteration.
This commit is contained in:
parent
426248098c
commit
b805f112c2
Notes:
sideshowbarker
2024-07-19 13:01:36 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/b805f112c21
1 changed files with 3 additions and 2 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue