filter/Filter: clarify that the FilterPCM() return value may be empty

And adjust TwoFilter accordingly.
This commit is contained in:
Max Kellermann
2024-11-05 12:24:26 +01:00
parent b7b4c6b4ea
commit d7ae512b5e
2 changed files with 9 additions and 2 deletions

View File

@@ -10,7 +10,14 @@
std::span<const std::byte>
TwoFilters::FilterPCM(std::span<const std::byte> 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<const std::byte>