Browse Source

fftools/ffmpeg: remove unncessary casts for *_thread() return values

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.
Anton Khirnov 1 year ago
parent
commit
2ee9362419

+ 2 - 2
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 */

+ 3 - 3
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)

+ 2 - 2
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)

+ 2 - 2
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;
 }

+ 3 - 3
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)
 {
@@ -2729,7 +2729,7 @@ fail:
     return AVERROR(ENOMEM);
 }
 
-static void *filter_thread(void *arg)
+static int filter_thread(void *arg)
 {
     FilterGraphPriv *fgp = arg;
     FilterGraph      *fg = &fgp->fg;
@@ -2843,7 +2843,7 @@ finish:
 
     fg_thread_uninit(&fgt);
 
-    return (void*)(intptr_t)ret;
+    return ret;
 }
 
 void fg_send_command(FilterGraph *fg, double time, const char *target,

+ 2 - 2
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)

+ 1 - 1
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));

+ 1 - 1
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,           \