filter/Internal: add method Reset()

This commit is contained in:
Max Kellermann 2017-01-11 15:24:12 +01:00
parent 7a3a793a12
commit 27c7891169
4 changed files with 26 additions and 1 deletions

View File

@ -52,6 +52,12 @@ public:
return out_audio_format;
}
/**
* Reset the filter's state, e.g. drop/flush buffers.
*/
virtual void Reset() {
}
/**
* Filters a block of PCM data.
*
@ -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;
};

View File

@ -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;
};

View File

@ -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)
{

View File

@ -52,6 +52,10 @@ public:
void Set(const AudioFormat &_out_audio_format);
void Reset() override {
state.Reset();
}
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
};