[FFmpeg-devel] [PATCH 1/2] ffmpeg: use thread wrappers for the thread message functionality

James Almer jamrial at gmail.com
Thu Jan 4 06:14:07 EET 2018


Signed-off-by: James Almer <jamrial at gmail.com>
---
 fftools/ffmpeg.c     | 19 ++++++++-----------
 fftools/ffmpeg.h     |  7 ++-----
 fftools/ffmpeg_opt.c |  2 +-
 3 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 6aff3366c5..528849a2c6 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -61,6 +61,7 @@
 #include "libavutil/timestamp.h"
 #include "libavutil/bprint.h"
 #include "libavutil/time.h"
+#include "libavutil/thread.h"
 #include "libavutil/threadmessage.h"
 #include "libavcodec/mathops.h"
 #include "libavformat/os_support.h"
@@ -98,10 +99,6 @@
 #include <conio.h>
 #endif
 
-#if HAVE_PTHREADS
-#include <pthread.h>
-#endif
-
 #include <time.h>
 
 #include "ffmpeg.h"
@@ -161,7 +158,7 @@ static struct termios oldtty;
 static int restore_tty;
 #endif
 
-#if HAVE_PTHREADS
+#if HAVE_THREADS
 static void free_input_threads(void);
 #endif
 
@@ -578,7 +575,7 @@ static void ffmpeg_cleanup(int ret)
 
         av_freep(&output_streams[i]);
     }
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     free_input_threads();
 #endif
     for (i = 0; i < nb_input_files; i++) {
@@ -3996,7 +3993,7 @@ static int check_keyboard_interaction(int64_t cur_time)
     return 0;
 }
 
-#if HAVE_PTHREADS
+#if HAVE_THREADS
 static void *input_thread(void *arg)
 {
     InputFile *f = arg;
@@ -4106,7 +4103,7 @@ static int get_input_packet(InputFile *f, AVPacket *pkt)
         }
     }
 
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     if (nb_input_files > 1)
         return get_input_packet_mt(f, pkt);
 #endif
@@ -4615,7 +4612,7 @@ static int transcode(void)
 
     timer_start = av_gettime_relative();
 
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     if ((ret = init_input_threads()) < 0)
         goto fail;
 #endif
@@ -4646,7 +4643,7 @@ static int transcode(void)
         /* dump report by using the output first video and audio streams */
         print_report(0, timer_start, cur_time);
     }
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     free_input_threads();
 #endif
 
@@ -4712,7 +4709,7 @@ static int transcode(void)
     ret = 0;
 
  fail:
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     free_input_threads();
 #endif
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 4e73d59082..8195f73e8b 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -25,10 +25,6 @@
 #include <stdio.h>
 #include <signal.h>
 
-#if HAVE_PTHREADS
-#include <pthread.h>
-#endif
-
 #include "cmdutils.h"
 
 #include "libavformat/avformat.h"
@@ -45,6 +41,7 @@
 #include "libavutil/hwcontext.h"
 #include "libavutil/pixfmt.h"
 #include "libavutil/rational.h"
+#include "libavutil/thread.h"
 #include "libavutil/threadmessage.h"
 
 #include "libswresample/swresample.h"
@@ -415,7 +412,7 @@ typedef struct InputFile {
     int rate_emu;
     int accurate_seek;
 
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     AVThreadMessageQueue *in_thread_queue;
     pthread_t thread;           /* thread reading from this file */
     int non_blocking;           /* reading packets from the thread should not block */
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index a6e36ac822..754c297b93 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -1161,7 +1161,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
     f->loop = o->loop;
     f->duration = 0;
     f->time_base = (AVRational){ 1, 1 };
-#if HAVE_PTHREADS
+#if HAVE_THREADS
     f->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 8;
 #endif
 
-- 
2.15.0



More information about the ffmpeg-devel mailing list