diff mbox series

[FFmpeg-devel,4/4] fftools/ffmpeg: set thread names

Message ID 20221018165307.28242-4-anton@khirnov.net
State Accepted
Commit 874a6f20902c91eb32b790b042ba77221f60c96b
Headers show
Series [FFmpeg-devel,1/4] lavu/thread: add an internal function for setting thread name | 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 Oct. 18, 2022, 4:53 p.m. UTC
---
 fftools/ffmpeg_demux.c | 9 +++++++++
 fftools/ffmpeg_mux.c   | 9 +++++++++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index 6e89f5999a..487053c592 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -177,6 +177,13 @@  static void ts_fixup(InputFile *ifile, AVPacket *pkt, int *repeat_pict)
         *repeat_pict = av_stream_get_parser(ist->st)->repeat_pict;
 }
 
+static void thread_set_name(InputFile *f)
+{
+    char name[16];
+    snprintf(name, sizeof(name), "dmx%d:%s", f->index, f->ctx->iformat->name);
+    ff_thread_setname(name);
+}
+
 static void *input_thread(void *arg)
 {
     InputFile *f = arg;
@@ -190,6 +197,8 @@  static void *input_thread(void *arg)
         goto finish;
     }
 
+    thread_set_name(f);
+
     while (1) {
         DemuxMsg msg = { NULL };
 
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index 2b70143978..778626e20f 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -184,6 +184,13 @@  static int sync_queue_process(Muxer *mux, OutputStream *ost, AVPacket *pkt)
     return 0;
 }
 
+static void thread_set_name(OutputFile *of)
+{
+    char name[16];
+    snprintf(name, sizeof(name), "mux%d:%s", of->index, of->format->name);
+    ff_thread_setname(name);
+}
+
 static void *muxer_thread(void *arg)
 {
     Muxer     *mux = arg;
@@ -197,6 +204,8 @@  static void *muxer_thread(void *arg)
         goto finish;
     }
 
+    thread_set_name(of);
+
     while (1) {
         OutputStream *ost;
         int stream_idx;