filter/ffmpeg: implement method Flush()
This commit is contained in:
parent
2c881c63ba
commit
fa29693550
|
@ -52,6 +52,8 @@ FfmpegFilter::ReadOutput()
|
|||
std::span<const std::byte>
|
||||
FfmpegFilter::FilterPCM(std::span<const std::byte> src)
|
||||
{
|
||||
assert(!flushed);
|
||||
|
||||
/* submit source data into the FFmpeg audio buffer source */
|
||||
|
||||
frame.Unref();
|
||||
|
@ -78,3 +80,16 @@ FfmpegFilter::FilterPCM(std::span<const std::byte> src)
|
|||
|
||||
return ReadOutput();
|
||||
}
|
||||
|
||||
std::span<const std::byte>
|
||||
FfmpegFilter::Flush()
|
||||
{
|
||||
if (!flushed) {
|
||||
if (int err = av_buffersrc_add_frame(&buffer_src, nullptr); err < 0)
|
||||
throw MakeFfmpegError(err, "av_buffersrc_write_frame() failed");
|
||||
|
||||
flushed = true;
|
||||
}
|
||||
|
||||
return ReadOutput();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,8 @@ class FfmpegFilter final : public Filter {
|
|||
const size_t in_audio_frame_size;
|
||||
const size_t out_audio_frame_size;
|
||||
|
||||
bool flushed = false;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @param _graph a checked and configured AVFilterGraph
|
||||
|
@ -46,6 +48,7 @@ public:
|
|||
|
||||
/* virtual methods from class Filter */
|
||||
std::span<const std::byte> FilterPCM(std::span<const std::byte> src) override;
|
||||
std::span<const std::byte> Flush() override;
|
||||
|
||||
private:
|
||||
std::span<const std::byte> ReadOutput();
|
||||
|
|
Loading…
Reference in New Issue