1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:47:35 +00:00

AudioServer: Clean up ClientAudioStream APIs

- Use Optional references instead of pointers
- Clean up some const and nullability weirdness
- Use proper error return value for get_next_sample
This commit is contained in:
kleines Filmröllchen 2023-08-11 15:57:31 +02:00 committed by Andrew Kaster
parent aacb4fc590
commit d905498fb6
3 changed files with 29 additions and 25 deletions

View file

@ -73,18 +73,20 @@ void Mixer::mix()
// Mix the buffers together into the output
for (auto& queue : active_mix_queues) {
if (!queue->client()) {
if (!queue->client().has_value()) {
queue->clear();
continue;
}
queue->volume().advance_time();
// FIXME: Perform sample extraction and mixing in two separate loops so they can be more easily vectorized.
for (auto& mixed_sample : mixed_buffer) {
Audio::Sample sample;
if (!queue->get_next_sample(sample, audiodevice_get_sample_rate()))
auto sample_or_error = queue->get_next_sample(audiodevice_get_sample_rate());
if (sample_or_error.is_error())
break;
if (queue->is_muted())
continue;
auto sample = sample_or_error.release_value();
sample.log_multiply(SAMPLE_HEADROOM);
sample.log_multiply(static_cast<float>(queue->volume()));
mixed_sample += sample;