diff mbox series

[FFmpeg-devel] lavc/pthread_frame: set worker thread names

Message ID 20221019090651.31082-1-anton@khirnov.net
State Accepted
Commit 5f82447dfc4df8540ab52534dafb5fbd5aa99497
Headers show
Series [FFmpeg-devel] lavc/pthread_frame: set worker thread names | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 fail Make failed
andriy/make_x86 fail Make failed

Commit Message

Anton Khirnov Oct. 19, 2022, 9:06 a.m. UTC
---
Yes, the space is limited and we could bikeshed until christmas about
the best way to use it.

Here's an attempt with an 'av' prefix, 'ft' (frame thread) changed to
df (decoder - frame thread), and only two characters guranteed for
thread index.
---
 libavcodec/pthread_frame.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index f8fddc5e4d..df82a4125f 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -179,6 +179,17 @@  static void async_unlock(FrameThreadContext *fctx)
     pthread_mutex_unlock(&fctx->async_mutex);
 }
 
+static void thread_set_name(PerThreadContext *p)
+{
+    AVCodecContext *avctx = p->avctx;
+    int idx = p - p->parent->threads;
+    char name[16];
+
+    snprintf(name, sizeof(name), "av:%.7s:df%d", avctx->codec->name, idx);
+
+    ff_thread_setname(name);
+}
+
 /**
  * Codec worker thread.
  *
@@ -192,6 +203,8 @@  static attribute_align_arg void *frame_worker_thread(void *arg)
     AVCodecContext *avctx = p->avctx;
     const FFCodec *codec = ffcodec(avctx->codec);
 
+    thread_set_name(p);
+
     pthread_mutex_lock(&p->mutex);
     while (1) {
         while (atomic_load(&p->state) == STATE_INPUT_READY && !p->die)