Skip to content

Commit e5294c8

Browse files
committed
OutputMixer: readability & documentation
1 parent b68716f commit e5294c8

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

src/AudioTools/CoreAudio/AudioOutput.h

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,19 @@ class HexDumpOutput : public AudioOutput {
365365
template <typename T>
366366
class OutputMixer : public Print {
367367
public:
368+
/**
369+
* @brief Default constructor. You must call setOutput() and setOutputCount() before use.
370+
* @param allocator Reference to the allocator to use for internal buffers (default: DefaultAllocatorRAM)
371+
*/
368372
OutputMixer(Allocator &allocator = DefaultAllocatorRAM) : allocator(allocator) {}
369373

374+
/**
375+
* @brief Constructor with output stream, number of input streams, and allocator.
376+
*
377+
* @param finalOutput Reference to the Print object for mixed audio output
378+
* @param outputStreamCount Number of input streams to mix
379+
* @param allocator Reference to the allocator to use for internal buffers (default: DefaultAllocatorRAM)
380+
*/
370381
OutputMixer(Print &finalOutput, int outputStreamCount, Allocator &allocator = DefaultAllocatorRAM) : OutputMixer(allocator) {
371382
setOutput(finalOutput);
372383
setOutputCount(outputStreamCount);
@@ -525,11 +536,11 @@ class OutputMixer : public Print {
525536
}
526537

527538
/// Resizes the buffer to the indicated number of bytes
528-
void resize(int size) {
529-
if (size != size_bytes) {
530-
allocate_buffers(size);
539+
void resize(int sizeBytes) {
540+
if (sizeBytes != size_bytes) {
541+
allocate_buffers(sizeBytes);
531542
}
532-
size_bytes = size;
543+
size_bytes = sizeBytes;
533544
}
534545

535546
/// Writes silence to the current stream buffer
@@ -589,8 +600,8 @@ class OutputMixer : public Print {
589600
BaseBuffer<T>* (*create_buffer_cb)(int size, Allocator &allocator) = create_buffer;
590601

591602
/// Creates a default ring buffer of the specified size
592-
static BaseBuffer<T>* create_buffer(int size, Allocator &allocator) {
593-
return new RingBuffer<T>(size / sizeof(T), allocator);
603+
static BaseBuffer<T>* create_buffer(int sizeBytes, Allocator &allocator) {
604+
return new RingBuffer<T>(sizeBytes / sizeof(T), allocator);
594605
}
595606

596607
/// Recalculates the total weights for normalization
@@ -602,13 +613,13 @@ class OutputMixer : public Print {
602613
}
603614

604615
/// Allocates ring buffers for all input streams
605-
void allocate_buffers(int size) {
616+
void allocate_buffers(int sizeBytes) {
606617
// allocate ringbuffers for each output
607618
for (int j = 0; j < output_count; j++) {
608619
if (buffers[j] != nullptr) {
609620
delete buffers[j];
610621
}
611-
buffers[j] = create_buffer(size, allocator);
622+
buffers[j] = create_buffer(sizeBytes, allocator);
612623
}
613624
}
614625

0 commit comments

Comments
 (0)