diff --git a/src/filter/Filter.hxx b/src/filter/Filter.hxx index 9174076e1..7196cc2d8 100644 --- a/src/filter/Filter.hxx +++ b/src/filter/Filter.hxx @@ -43,7 +43,7 @@ public: * @param src the input buffer * @return the output buffer (will be invalidated by deleting * this object or any call to Reset(), FilterPCM() or - * Flush()) + * Flush()); may be empty if no output is currently available */ virtual std::span FilterPCM(std::span src) = 0; diff --git a/src/filter/plugins/TwoFilters.cxx b/src/filter/plugins/TwoFilters.cxx index 2ffcae1ad..ee67d9073 100644 --- a/src/filter/plugins/TwoFilters.cxx +++ b/src/filter/plugins/TwoFilters.cxx @@ -10,7 +10,14 @@ std::span TwoFilters::FilterPCM(std::span src) { - return second->FilterPCM(first->FilterPCM(src)); + if (const auto dest = first->FilterPCM(src); dest.empty()) [[unlikely]] + /* no output from the first filter; pass the empty + buffer on, do not call the second filter */ + return dest; + else + /* pass output from the first filter to the second + filter and return its result */ + return second->FilterPCM(dest); } std::span