Skip to content

Commit

Permalink
OutputMixer: flushMixer() allow 0 lines
Browse files Browse the repository at this point in the history
  • Loading branch information
pschatzmann committed Jun 20, 2024
1 parent d47537c commit f6acdb0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/AudioTools/AudioOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,11 @@ class OutputMixer : public Print {
size_t write(const uint8_t *buffer_c, size_t bytes) override {
size_t result = write(stream_idx, buffer_c, bytes);
// after writing the last stream we flush
if (is_auto_index) stream_idx++;
if (stream_idx >= output_count) {
flushMixer();
if (is_auto_index) {
stream_idx++;
if (stream_idx >= output_count) {
flushMixer();
}
}
return result;
}
Expand Down Expand Up @@ -418,9 +420,12 @@ class OutputMixer : public Print {
bool result = false;

// determine ringbuffer with mininum available data
size_t samples = size_bytes / sizeof(T);
size_t samples = 0;
for (int j = 0; j < output_count; j++) {
samples = MIN(samples, (size_t)buffers[j]->available());
int available_samples = buffers[j]->available();
if (available_samples > 0){
samples = MIN(size_bytes / sizeof(T), (size_t)available_samples);
}
}

if (samples > 0) {
Expand Down

0 comments on commit f6acdb0

Please sign in to comment.