From 8f4e1ece7512c2b911491d87edc475b803c3989c Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 28 Aug 2024 09:43:41 +1000 Subject: Some minor cleanup, docs, assertions --- src/tangara/audio/processor.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/tangara/audio/processor.cpp') diff --git a/src/tangara/audio/processor.cpp b/src/tangara/audio/processor.cpp index 29124232..aa2604b5 100644 --- a/src/tangara/audio/processor.cpp +++ b/src/tangara/audio/processor.cpp @@ -1,11 +1,10 @@ /* - * Copyright 2023 jacqueline + * Copyright 2024 jacqueline * * SPDX-License-Identifier: GPL-3.0-only */ #include "audio/processor.hpp" -#include #include #include @@ -38,6 +37,11 @@ static const size_t kSourceBufferLength = kSampleBufferLength * 2; namespace audio { +/* + * The output format to convert all sources to. This is currently fixed because + * the Bluetooth output doesn't support runtime configuration of its input + * format. + */ static const I2SAudioOutput::Format kTargetFormat{ .sample_rate = 48000, .num_channels = 2, @@ -60,7 +64,10 @@ SampleProcessor::~SampleProcessor() { } auto SampleProcessor::SetOutput(std::shared_ptr output) -> void { + // Make sure our fixed output format is valid. + assert(output->PrepareFormat(kTargetFormat) == kTargetFormat); output->Configure(kTargetFormat); + // FIXME: We should add synchronisation here, but we should be careful // about not impacting performance given that the output will change only // very rarely (if ever). @@ -337,7 +344,7 @@ auto SampleProcessor::discardCommand(Args& command) -> void { if (command.samples_available) { unprocessed_samples_ += command.samples_available; } - // End of stream commands can just be dropped. Without further actions. + // End of stream commands can just be dropped without further action. } SampleProcessor::Buffer::Buffer() -- cgit v1.2.3