[FFmpeg-cvslog] fftools/ffmpeg: drop free_input_threads()

Anton Khirnov git at videolan.org
Tue Oct 25 12:16:09 EEST 2022


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Oct 17 12:35:22 2022 +0200| [c20977c4e038b7c4b37ddcb300cf13a5881cc724] | committer: Anton Khirnov

fftools/ffmpeg: drop free_input_threads()

Stop demuxer threads in ifile_close() instead. Simplifies the demuxer
API.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c20977c4e038b7c4b37ddcb300cf13a5881cc724
---

 fftools/ffmpeg.c       |  4 ----
 fftools/ffmpeg.h       |  1 -
 fftools/ffmpeg_demux.c | 17 ++++++-----------
 3 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 842ed2fa66..93d1551e1e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -555,7 +555,6 @@ static void ffmpeg_cleanup(int ret)
     for (i = 0; i < nb_output_files; i++)
         of_close(&output_files[i]);
 
-    free_input_threads();
     for (i = 0; i < nb_input_files; i++)
         ifile_close(&input_files[i]);
 
@@ -3934,7 +3933,6 @@ static int transcode(void)
         /* dump report by using the output first video and audio streams */
         print_report(0, timer_start, cur_time);
     }
-    free_input_threads();
 
     /* at the end of stream, we must flush the decoder buffers */
     for (i = 0; i < nb_input_streams; i++) {
@@ -3987,8 +3985,6 @@ static int transcode(void)
     ret = 0;
 
  fail:
-    free_input_threads();
-
     return ret;
 }
 
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 1fd29fb0db..6ec0710075 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -771,7 +771,6 @@ void ifile_close(InputFile **f);
  * - a negative error code on failure
  */
 int ifile_get_packet(InputFile *f, AVPacket **pkt);
-void free_input_threads(void);
 
 #define SPECIFIER_OPT_FMT_str  "%s"
 #define SPECIFIER_OPT_FMT_i    "%i"
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 880e56d2e3..f94a901d05 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -322,12 +322,12 @@ finish:
     return NULL;
 }
 
-static void free_input_thread(int i)
+static void thread_stop(Demuxer *d)
 {
-    InputFile *f = input_files[i];
+    InputFile *f = &d->f;
     DemuxMsg msg;
 
-    if (!f || !f->in_thread_queue)
+    if (!f->in_thread_queue)
         return;
     av_thread_message_queue_set_err_send(f->in_thread_queue, AVERROR_EOF);
     while (av_thread_message_queue_recv(f->in_thread_queue, &msg, 0) >= 0)
@@ -338,14 +338,6 @@ static void free_input_thread(int i)
     av_thread_message_queue_free(&f->audio_duration_queue);
 }
 
-void free_input_threads(void)
-{
-    int i;
-
-    for (i = 0; i < nb_input_files; i++)
-        free_input_thread(i);
-}
-
 static int thread_start(Demuxer *d)
 {
     int ret;
@@ -442,10 +434,13 @@ int ifile_get_packet(InputFile *f, AVPacket **pkt)
 void ifile_close(InputFile **pf)
 {
     InputFile *f = *pf;
+    Demuxer   *d = demuxer_from_ifile(f);
 
     if (!f)
         return;
 
+    thread_stop(d);
+
     avformat_close_input(&f->ctx);
 
     av_freep(pf);



More information about the ffmpeg-cvslog mailing list