[FFmpeg-devel] [PATCH 10/18] fftools/ffmpeg: remove unncessary casts for *_thread() return values

Anton Khirnov anton at khirnov.net
Wed Mar 6 13:03:11 EET 2024


These functions used to be passed directly to pthread_create(), which
required them to return void*. This is no longer the case, so they can
return a plain int.
---
 fftools/ffmpeg.h        | 4 ++--
 fftools/ffmpeg_dec.c    | 6 +++---
 fftools/ffmpeg_demux.c  | 4 ++--
 fftools/ffmpeg_enc.c    | 4 ++--
 fftools/ffmpeg_filter.c | 6 +++---
 fftools/ffmpeg_mux.c    | 4 ++--
 fftools/ffmpeg_sched.c  | 2 +-
 fftools/ffmpeg_sched.h  | 2 +-
 8 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1a60f035b0..1966817bc3 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -832,7 +832,7 @@ void update_benchmark(const char *fmt, ...);
 const char *opt_match_per_type_str(const SpecifierOptList *sol,
                                    char mediatype);
 
-void *muxer_thread(void *arg);
-void *encoder_thread(void *arg);
+int muxer_thread(void *arg);
+int encoder_thread(void *arg);
 
 #endif /* FFTOOLS_FFMPEG_H */
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 7005ada527..3bf7ab4960 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -124,7 +124,7 @@ static const AVClass dec_class = {
     .item_name                 = dec_item_name,
 };
 
-static void *decoder_thread(void *arg);
+static int decoder_thread(void *arg);
 
 static int dec_alloc(DecoderPriv **pdec, Scheduler *sch, int send_end_ts)
 {
@@ -789,7 +789,7 @@ fail:
     return AVERROR(ENOMEM);
 }
 
-static void *decoder_thread(void *arg)
+static int decoder_thread(void *arg)
 {
     DecoderPriv  *dp = arg;
     DecThreadContext dt;
@@ -884,7 +884,7 @@ static void *decoder_thread(void *arg)
 finish:
     dec_thread_uninit(&dt);
 
-    return (void*)(intptr_t)ret;
+    return ret;
 }
 
 static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts)
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 032a96567f..47312c9fe1 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -675,7 +675,7 @@ static int demux_thread_init(DemuxThreadContext *dt)
     return 0;
 }
 
-static void *input_thread(void *arg)
+static int input_thread(void *arg)
 {
     Demuxer   *d = arg;
     InputFile *f = &d->f;
@@ -780,7 +780,7 @@ static void *input_thread(void *arg)
 finish:
     demux_thread_uninit(&dt);
 
-    return (void*)(intptr_t)ret;
+    return ret;
 }
 
 static void demux_final_stats(Demuxer *d)
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index bdba50df03..1ddef46d03 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -870,7 +870,7 @@ fail:
     return AVERROR(ENOMEM);
 }
 
-void *encoder_thread(void *arg)
+int encoder_thread(void *arg)
 {
     OutputStream *ost = arg;
     Encoder        *e = ost->enc;
@@ -948,5 +948,5 @@ void *encoder_thread(void *arg)
 finish:
     enc_thread_uninit(&et);
 
-    return (void*)(intptr_t)ret;
+    return ret;
 }
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 6438cbd73b..a29008387a 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -626,7 +626,7 @@ static int ifilter_has_all_input_formats(FilterGraph *fg)
     return 1;
 }
 
-static void *filter_thread(void *arg);
+static int filter_thread(void *arg);
 
 static char *describe_filter_link(FilterGraph *fg, AVFilterInOut *inout, int in)
 {
@@ -2735,7 +2735,7 @@ fail:
     return AVERROR(ENOMEM);
 }
 
-static void *filter_thread(void *arg)
+static int filter_thread(void *arg)
 {
     FilterGraphPriv *fgp = arg;
     FilterGraph      *fg = &fgp->fg;
@@ -2849,7 +2849,7 @@ finish:
 
     fg_thread_uninit(&fgt);
 
-    return (void*)(intptr_t)ret;
+    return ret;
 }
 
 void fg_send_command(FilterGraph *fg, double time, const char *target,
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 6ba54b878b..59befefab2 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -404,7 +404,7 @@ fail:
     return AVERROR(ENOMEM);
 }
 
-void *muxer_thread(void *arg)
+int muxer_thread(void *arg)
 {
     Muxer     *mux = arg;
     OutputFile *of = &mux->of;
@@ -453,7 +453,7 @@ void *muxer_thread(void *arg)
 finish:
     mux_thread_uninit(&mt);
 
-    return (void*)(intptr_t)ret;
+    return ret;
 }
 
 static int of_streamcopy(OutputFile *of, OutputStream *ost, AVPacket *pkt)
diff --git a/fftools/ffmpeg_sched.c b/fftools/ffmpeg_sched.c
index 1144fce958..cf9b0c836e 100644
--- a/fftools/ffmpeg_sched.c
+++ b/fftools/ffmpeg_sched.c
@@ -2226,7 +2226,7 @@ static void *task_wrapper(void *arg)
     int ret;
     int err = 0;
 
-    ret = (intptr_t)task->func(task->func_arg);
+    ret = task->func(task->func_arg);
     if (ret < 0)
         av_log(task->func_arg, AV_LOG_ERROR,
                "Task finished with error code: %d (%s)\n", ret, av_err2str(ret));
diff --git a/fftools/ffmpeg_sched.h b/fftools/ffmpeg_sched.h
index 95f9c1d4db..fc6711f9c3 100644
--- a/fftools/ffmpeg_sched.h
+++ b/fftools/ffmpeg_sched.h
@@ -102,7 +102,7 @@ typedef struct SchedulerNode {
     unsigned                idx_stream;
 } SchedulerNode;
 
-typedef void* (*SchThreadFunc)(void *arg);
+typedef int (*SchThreadFunc)(void *arg);
 
 #define SCH_DSTREAM(file, stream)                           \
     (SchedulerNode){ .type = SCH_NODE_TYPE_DEMUX,           \
-- 
2.43.0



More information about the ffmpeg-devel mailing list