diff options
author | Max Kellermann <max@musicpd.org> | 2018-02-09 19:04:45 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-02-09 19:04:45 +0100 |
commit | 56b74ad990d8d6180fe47fbb271469b2825d2d42 (patch) | |
tree | 544941166e00acfb31283987357a84c6958e0d04 /src | |
parent | 6de92bb42bb61e7eb849bd554429579d6c61a77e (diff) |
filter/convert: add method IsActive()
Diffstat (limited to 'src')
-rw-r--r-- | src/filter/plugins/ConvertFilterPlugin.cxx | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/filter/plugins/ConvertFilterPlugin.cxx b/src/filter/plugins/ConvertFilterPlugin.cxx index 1ede2c03e..bcc70fcd5 100644 --- a/src/filter/plugins/ConvertFilterPlugin.cxx +++ b/src/filter/plugins/ConvertFilterPlugin.cxx @@ -57,6 +57,11 @@ public: } ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override; + +private: + bool IsActive() const noexcept { + return out_audio_format != in_audio_format; + } }; class PreparedConvertFilter final : public PreparedFilter { @@ -80,7 +85,7 @@ ConvertFilter::Set(const AudioFormat &_out_audio_format) /* no change */ return; - if (out_audio_format != in_audio_format) { + if (IsActive()) { out_audio_format = in_audio_format; state.Close(); } @@ -111,7 +116,7 @@ ConvertFilter::~ConvertFilter() { assert(in_audio_format.IsValid()); - if (out_audio_format != in_audio_format) + if (IsActive()) state.Close(); } @@ -120,11 +125,10 @@ ConvertFilter::FilterPCM(ConstBuffer<void> src) { assert(in_audio_format.IsValid()); - if (out_audio_format == in_audio_format) + return IsActive() + ? state.Convert(src) /* optimized special case: no-op */ - return src; - - return state.Convert(src); + : src; } const FilterPlugin convert_filter_plugin = { |