diff mbox series

[FFmpeg-devel,18/47] fftools/ffmpeg_filter: replace remaining exit_program() with error codes

Message ID 20230715104611.17902-18-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/47] fftools/ffmpeg_mux_init: handle pixel format endianness | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov July 15, 2023, 10:45 a.m. UTC
---
 fftools/ffmpeg.h        |  2 +-
 fftools/ffmpeg_filter.c | 15 ++++++++++-----
 fftools/ffmpeg_opt.c    |  4 +++-
 3 files changed, 14 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index d7e16d034f..043eb5e6ec 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -717,7 +717,7 @@  const AVCodec *find_codec_or_die(void *logctx, const char *name,
                                  enum AVMediaType type, int encoder);
 int parse_and_set_vsync(const char *arg, int *vsync_var, int file_idx, int st_idx, int is_global);
 
-void check_filter_outputs(void);
+int check_filter_outputs(void);
 int filtergraph_is_simple(const FilterGraph *fg);
 int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
                             char *graph_desc);
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 79e034d248..ed0df9f320 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -1246,7 +1246,7 @@  static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter,
 {
     if (!ofilter->ost) {
         av_log(fg, AV_LOG_FATAL, "Filter %s has an unconnected output\n", ofilter->name);
-        exit_program(1);
+        return AVERROR(EINVAL);
     }
 
     switch (avfilter_pad_get_type(out->filter_ctx->output_pads, out->pad_idx)) {
@@ -1256,7 +1256,7 @@  static int configure_output_filter(FilterGraph *fg, OutputFilter *ofilter,
     }
 }
 
-void check_filter_outputs(void)
+int check_filter_outputs(void)
 {
     int i;
     for (i = 0; i < nb_filtergraphs; i++) {
@@ -1266,10 +1266,12 @@  void check_filter_outputs(void)
             if (!output->ost) {
                 av_log(filtergraphs[i], AV_LOG_FATAL,
                        "Filter %s has an unconnected output\n", output->name);
-                exit_program(1);
+                return AVERROR(EINVAL);
             }
         }
     }
+
+    return 0;
 }
 
 static void sub2video_prepare(InputFilterPriv *ifp)
@@ -1570,8 +1572,11 @@  static int configure_filtergraph(FilterGraph *fg)
         }
     avfilter_inout_free(&inputs);
 
-    for (cur = outputs, i = 0; cur; cur = cur->next, i++)
-        configure_output_filter(fg, fg->outputs[i], cur);
+    for (cur = outputs, i = 0; cur; cur = cur->next, i++) {
+        ret = configure_output_filter(fg, fg->outputs[i], cur);
+        if (ret < 0)
+            return ret;
+    }
     avfilter_inout_free(&outputs);
 
     if (fgp->disable_conversions)
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 300f042660..44bf263621 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1301,7 +1301,9 @@  int ffmpeg_parse_options(int argc, char **argv)
 
     apply_sync_offsets();
 
-    check_filter_outputs();
+    ret = check_filter_outputs();
+    if (ret < 0)
+        goto fail;
 
 fail:
     uninit_parse_context(&octx);