Browse Source

Clear audio output in Device before Ports process buffers.

tags/v2.2.2
Andrew Belt 1 year ago
parent
commit
908517c890
1 changed files with 3 additions and 5 deletions
  1. +3
    -5
      src/audio.cpp

+ 3
- 5
src/audio.cpp View File

@@ -31,6 +31,9 @@ void Device::unsubscribe(Port* port) {
}

void Device::processBuffer(const float* input, int inputStride, float* output, int outputStride, int frames) {
// Zero output since Ports might not write to all elements, or no Ports exist
std::fill_n(output, frames * outputStride, 0.f);

std::lock_guard<std::mutex> lock(processMutex);
for (Port* port : subscribed) {
// Setting the thread context should probably be the responsibility of Port, but because processInput() etc are overridden, this is the only good place for it.
@@ -45,11 +48,6 @@ void Device::processBuffer(const float* input, int inputStride, float* output, i
contextSet(port->context);
port->processOutput(output + port->outputOffset, outputStride, frames);
}

if (subscribed.empty()) {
// Clear output if no Port writes values to it.
std::fill_n(output, frames * outputStride, 0.f);
}
}

void Device::onStartStream() {


Loading…
Cancel
Save