Skip to content

Commit 3b071f2

Browse files
committed
OutputMixer: add missing comments
1 parent cd98763 commit 3b071f2

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/AudioTools/CoreAudio/AudioOutput.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -372,8 +372,10 @@ class OutputMixer : public Print {
372372
setOutputCount(outputStreamCount);
373373
}
374374

375+
/// Sets the final output destination for mixed audio
375376
void setOutput(Print &finalOutput) { p_final_output = &finalOutput; }
376377

378+
/// Sets the number of input streams to mix
377379
void setOutputCount(int count) {
378380
output_count = count;
379381
buffers.resize(count);
@@ -419,6 +421,7 @@ class OutputMixer : public Print {
419421
/// Number of stremams to which are mixed together
420422
int size() { return output_count; }
421423

424+
/// Single byte write - not supported, returns 0
422425
size_t write(uint8_t) override { return 0; }
423426

424427
/// Write the data from a simgle stream which will be mixed together (the
@@ -509,6 +512,7 @@ class OutputMixer : public Print {
509512
return;
510513
}
511514

515+
/// Returns the minimum number of samples available across all buffers
512516
int availableSamples() {
513517
size_t samples = 0;
514518
for (int j = 0; j < output_count; j++) {
@@ -528,13 +532,15 @@ class OutputMixer : public Print {
528532
size_bytes = size;
529533
}
530534

535+
/// Writes silence to the current stream buffer
531536
size_t writeSilence(size_t bytes) {
532537
if (bytes == 0) return 0;
533538
uint8_t silence[bytes];
534539
memset(silence, 0, bytes);
535540
return write(stream_idx, silence, bytes);
536541
}
537542

543+
/// Writes silence to the specified stream buffer
538544
size_t writeSilence(int idx, size_t bytes){
539545
if (bytes == 0) return 0;
540546
uint8_t silence[bytes];
@@ -581,17 +587,20 @@ class OutputMixer : public Print {
581587
bool is_auto_index = true;
582588
BaseBuffer<T>* (*create_buffer_cb)(int size) = create_buffer;
583589

590+
/// Creates a default ring buffer of the specified size
584591
static BaseBuffer<T>* create_buffer(int size) {
585592
return new RingBuffer<T>(size / sizeof(T));
586593
}
587594

595+
/// Recalculates the total weights for normalization
588596
void update_total_weights() {
589597
total_weights = 0.0;
590598
for (int j = 0; j < weights.size(); j++) {
591599
total_weights += weights[j];
592600
}
593601
}
594602

603+
/// Allocates ring buffers for all input streams
595604
void allocate_buffers(int size) {
596605
// allocate ringbuffers for each output
597606
for (int j = 0; j < output_count; j++) {
@@ -602,6 +611,7 @@ class OutputMixer : public Print {
602611
}
603612
}
604613

614+
/// Releases memory for all ring buffers
605615
void free_buffers() {
606616
// allocate ringbuffers for each output
607617
for (int j = 0; j < output_count; j++) {

0 commit comments

Comments
 (0)