lib/ffmpeg/Filter: add ParseSingleInOut()

Merge some duplicate code.
This commit is contained in:
Max Kellermann
2021-08-24 13:26:28 +02:00
parent 71a5311b06
commit 7b4225aa1f
4 changed files with 18 additions and 23 deletions

View File

@@ -47,17 +47,7 @@ PreparedFfmpegFilter::Open(AudioFormat &in_audio_format)
auto &buffer_sink = Ffmpeg::MakeAudioBufferSink(*graph);
Ffmpeg::FilterInOut io_sink("out", buffer_sink);
Ffmpeg::FilterInOut io_src("in", buffer_src);
auto io = graph.Parse(graph_string, std::move(io_sink),
std::move(io_src));
if (io.first.get() != nullptr)
throw std::runtime_error("FFmpeg filter has an open input");
if (io.second.get() != nullptr)
throw std::runtime_error("FFmpeg filter has an open output");
graph.ParseSingleInOut(graph_string, buffer_sink, buffer_src);
graph.CheckAndConfigure();
const auto out_audio_format =

View File

@@ -48,18 +48,7 @@ OpenHdcdFilter(AudioFormat &in_audio_format)
auto &buffer_sink = Ffmpeg::MakeAudioBufferSink(*graph);
Ffmpeg::FilterInOut io_sink("out", buffer_sink);
Ffmpeg::FilterInOut io_src("in", buffer_src);
auto io = graph.Parse(hdcd_graph, std::move(io_sink),
std::move(io_src));
if (io.first.get() != nullptr)
throw std::runtime_error("FFmpeg filter has an open input");
if (io.second.get() != nullptr)
throw std::runtime_error("FFmpeg filter has an open output");
graph.ParseSingleInOut(hdcd_graph, buffer_sink, buffer_src);
graph.CheckAndConfigure();
auto out_audio_format = in_audio_format;