AudioServer: Stop re-creating the device stream buffer
The buffer provided to `OutputMemoryStream` was made a private class member. This is because there is no reason to re-create it in every iteration. Also, the logic becomes more symmetric with `m_zero_filled_buffer` which is already a class member.
This commit is contained in:
parent
b22c840963
commit
457fda6354
Notes:
sideshowbarker
2024-07-17 04:33:59 +09:00
Author: https://github.com/achronop Commit: https://github.com/SerenityOS/serenity/commit/457fda6354 Pull-request: https://github.com/SerenityOS/serenity/pull/16003 Reviewed-by: https://github.com/kleinesfilmroellchen ✅
2 changed files with 2 additions and 2 deletions
|
@ -100,8 +100,7 @@ void Mixer::mix()
|
|||
if (m_muted || m_main_volume < 0.01) {
|
||||
m_device->write(m_zero_filled_buffer.data(), static_cast<int>(m_zero_filled_buffer.size()));
|
||||
} else {
|
||||
Array<u8, HARDWARE_BUFFER_SIZE_BYTES> buffer;
|
||||
OutputMemoryStream stream { buffer };
|
||||
OutputMemoryStream stream { m_stream_buffer };
|
||||
|
||||
for (auto& mixed_sample : mixed_buffer) {
|
||||
mixed_sample.log_multiply(static_cast<float>(m_main_volume));
|
||||
|
|
|
@ -133,6 +133,7 @@ private:
|
|||
NonnullRefPtr<Core::ConfigFile> m_config;
|
||||
RefPtr<Core::Timer> m_config_write_timer;
|
||||
|
||||
Array<u8, HARDWARE_BUFFER_SIZE_BYTES> m_stream_buffer;
|
||||
Array<u8, HARDWARE_BUFFER_SIZE_BYTES> const m_zero_filled_buffer {};
|
||||
|
||||
void mix();
|
||||
|
|
Loading…
Add table
Reference in a new issue