filter/Filter: clarify that the FilterPCM() return value may be empty
And adjust TwoFilter accordingly.
This commit is contained in:
parent
b7b4c6b4ea
commit
d7ae512b5e
|
@ -43,7 +43,7 @@ public:
|
||||||
* @param src the input buffer
|
* @param src the input buffer
|
||||||
* @return the output buffer (will be invalidated by deleting
|
* @return the output buffer (will be invalidated by deleting
|
||||||
* this object or any call to Reset(), FilterPCM() or
|
* this object or any call to Reset(), FilterPCM() or
|
||||||
* Flush())
|
* Flush()); may be empty if no output is currently available
|
||||||
*/
|
*/
|
||||||
virtual std::span<const std::byte> FilterPCM(std::span<const std::byte> src) = 0;
|
virtual std::span<const std::byte> FilterPCM(std::span<const std::byte> src) = 0;
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,14 @@
|
||||||
std::span<const std::byte>
|
std::span<const std::byte>
|
||||||
TwoFilters::FilterPCM(std::span<const std::byte> src)
|
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>
|
std::span<const std::byte>
|
||||||
|
|
Loading…
Reference in New Issue