diff mbox series

[FFmpeg-devel,21/47] fftools/ffmpeg_filter: return error codes from set_channel_layout() instead of aborting

Message ID 20230715104611.17902-21-anton@khirnov.net
State Accepted
Commit cb8242db8d0191fbb51f06eca6bee2c1a2c0c075
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_filter.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 485154a448..470d7b1f02 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -583,7 +583,7 @@  static int ifilter_bind_ist(InputFilter *ifilter, InputStream *ist)
     return 0;
 }
 
-static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
+static int set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
 {
     const AVCodec *c = ost->enc_ctx->codec;
     int i, err;
@@ -592,8 +592,8 @@  static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
         /* Pass the layout through for all orders but UNSPEC */
         err = av_channel_layout_copy(&f->ch_layout, &ost->enc_ctx->ch_layout);
         if (err < 0)
-            report_and_exit(AVERROR(ENOMEM));
-        return;
+            return err;
+        return 0;
     }
 
     /* Requested layout is of order UNSPEC */
@@ -601,7 +601,7 @@  static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
         /* Use the default native layout for the requested amount of channels when the
            encoder doesn't have a list of supported layouts */
         av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
-        return;
+        return 0;
     }
     /* Encoder has a list of supported layouts. Pick the first layout in it with the
        same amount of channels as the requested layout */
@@ -613,12 +613,14 @@  static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
         /* Use it if one is found */
         err = av_channel_layout_copy(&f->ch_layout, &c->ch_layouts[i]);
         if (err < 0)
-            report_and_exit(AVERROR(ENOMEM));
-        return;
+            return err;
+        return 0;
     }
     /* If no layout for the amount of channels requested was found, use the default
        native layout for it. */
     av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
+
+    return 0;
 }
 
 int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
@@ -682,7 +684,9 @@  int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
             ofp->sample_rates = c->supported_samplerates;
         }
         if (ost->enc_ctx->ch_layout.nb_channels) {
-            set_channel_layout(ofp, ost);
+            int ret = set_channel_layout(ofp, ost);
+            if (ret < 0)
+                return ret;
         } else if (c->ch_layouts) {
             ofp->ch_layouts = c->ch_layouts;
         }