Commit 27c78911 authored by Max Kellermann's avatar Max Kellermann

filter/Internal: add method Reset()

parent 7a3a793a
......@@ -53,6 +53,12 @@ public:
}
/**
* Reset the filter's state, e.g. drop/flush buffers.
*/
virtual void Reset() {
}
/**
* Filters a block of PCM data.
*
* Throws std::runtime_error on error.
......@@ -60,7 +66,7 @@ public:
* @param src the input buffer
* @return the destination buffer on success (will be
* invalidated by deleting this object or the next FilterPCM()
* call)
* or Reset() call)
*/
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src) = 0;
};
......
......@@ -48,6 +48,13 @@ public:
:Filter(_filter->GetOutAudioFormat()),
filter(std::move(_filter)), convert(std::move(_convert)) {}
void Reset() override {
filter->Reset();
if (convert)
convert->Reset();
}
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
};
......
......@@ -61,6 +61,7 @@ public:
}
/* virtual methods from class Filter */
void Reset() override;
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
};
......@@ -130,6 +131,13 @@ PreparedChainFilter::Open(AudioFormat &in_audio_format)
return chain.release();
}
void
ChainFilter::Reset()
{
for (auto &child : children)
child.filter->Reset();
}
ConstBuffer<void>
ChainFilter::FilterPCM(ConstBuffer<void> src)
{
......
......@@ -52,6 +52,10 @@ public:
void Set(const AudioFormat &_out_audio_format);
void Reset() override {
state.Reset();
}
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment