diff --git a/src/filter/plugins/TwoFilters.hxx b/src/filter/plugins/TwoFilters.hxx index 28fa31948..d5fa77cd2 100644 --- a/src/filter/plugins/TwoFilters.hxx +++ b/src/filter/plugins/TwoFilters.hxx @@ -65,4 +65,23 @@ public: std::unique_ptr Open(AudioFormat &audio_format) override; }; +/** + * Create a #PreparedTwoFilters instance, but only if both parameters + * are not nullptr. + */ +template +static std::unique_ptr +ChainFilters(F &&first, S &&second, N &&second_name) noexcept +{ + if (!second) + return std::forward(first); + + if (!first) + return std::forward(second); + + return std::make_unique(std::forward(first), + std::forward(second), + std::forward(second_name)); +} + #endif