From 71480f2d1cd96c1ca5b2888f82bf33d290d60228 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 25 Jan 2017 19:20:28 +0100 Subject: [PATCH] Give all of our threads meaningful names, to aid with debugging. --- alsa_pool.cpp | 7 +++++++ bmusb | 2 +- decklink_capture.cpp | 4 ++++ decklink_output.cpp | 2 ++ midi_mapper.cpp | 3 +++ mixer.cpp | 5 +++++ quicksync_encoder.cpp | 4 ++++ 7 files changed, 26 insertions(+), 1 deletion(-) diff --git a/alsa_pool.cpp b/alsa_pool.cpp index bcda163..3a4a5b0 100644 --- a/alsa_pool.cpp +++ b/alsa_pool.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -134,6 +135,10 @@ void ALSAPool::probe_device_retry_thread_func(unsigned card_index, unsigned dev_ char address[256]; snprintf(address, sizeof(address), "hw:%d,%d", card_index, dev_index); + char thread_name[16]; + snprintf(thread_name, sizeof(thread_name), "Reprobe_hw:%d,%d", card_index, dev_index); + pthread_setname_np(pthread_self(), thread_name); + for ( ;; ) { // Termination condition within the loop. sleep(1); @@ -288,6 +293,8 @@ void ALSAPool::init() void ALSAPool::inotify_thread_func() { + pthread_setname_np(pthread_self(), "ALSA_Hotplug"); + int inotify_fd = inotify_init(); if (inotify_fd == -1) { perror("inotify_init()"); diff --git a/bmusb b/bmusb index 9053593..1833f74 160000 --- a/bmusb +++ b/bmusb @@ -1 +1 @@ -Subproject commit 9053593313b47bd5fd6b888bec9809bf4aacc8a9 +Subproject commit 1833f747a9008f38e5597622f2e3dbce3340e2cb diff --git a/decklink_capture.cpp b/decklink_capture.cpp index 92fd6ae..d38cc73 100644 --- a/decklink_capture.cpp +++ b/decklink_capture.cpp @@ -8,6 +8,7 @@ #ifdef __SSE2__ #include #endif +#include #include #include #include @@ -301,6 +302,9 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived( IDeckLinkAudioInputPacket *audio_frame) { if (!done_init) { + char thread_name[16]; + snprintf(thread_name, sizeof(thread_name), "DeckLink_C_%d", card_index); + pthread_setname_np(pthread_self(), thread_name); if (has_dequeue_callbacks) { dequeue_init_callback(); } diff --git a/decklink_output.cpp b/decklink_output.cpp index c5bf96b..21baf61 100644 --- a/decklink_output.cpp +++ b/decklink_output.cpp @@ -1,6 +1,7 @@ #include #include #include // Must be above the Xlib includes. +#include #include @@ -361,6 +362,7 @@ unique_ptr DeckLinkOutput::get_frame() void DeckLinkOutput::present_thread_func() { + pthread_setname_np(pthread_self(), "DeckLinkOutput"); for ( ;; ) { unique_ptr frame; { diff --git a/midi_mapper.cpp b/midi_mapper.cpp index 6ce5030..d03f382 100644 --- a/midi_mapper.cpp +++ b/midi_mapper.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -148,6 +149,8 @@ ControllerReceiver *MIDIMapper::set_receiver(ControllerReceiver *new_receiver) void MIDIMapper::thread_func() { + pthread_setname_np(pthread_self(), "MIDIMapper"); + snd_seq_t *seq; int err; diff --git a/mixer.cpp b/mixer.cpp index b5311a3..457734d 100644 --- a/mixer.cpp +++ b/mixer.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -565,6 +566,8 @@ void Mixer::bm_hotplug_remove(unsigned card_index) void Mixer::thread_func() { + pthread_setname_np(pthread_self(), "Mixer_OpenGL"); + eglBindAPI(EGL_OPENGL_API); QOpenGLContext *context = create_context(mixer_surface); if (!make_current(context, mixer_surface)) { @@ -932,6 +935,8 @@ void Mixer::render_one_frame(int64_t duration) void Mixer::audio_thread_func() { + pthread_setname_np(pthread_self(), "Mixer_Audio"); + while (!should_quit) { AudioTask task; diff --git a/quicksync_encoder.cpp b/quicksync_encoder.cpp index 875b264..f0ec210 100644 --- a/quicksync_encoder.cpp +++ b/quicksync_encoder.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -1430,6 +1431,7 @@ void QuickSyncEncoderImpl::storage_task_enqueue(storage_task task) void QuickSyncEncoderImpl::storage_task_thread() { + pthread_setname_np(pthread_self(), "QS_Storage"); for ( ;; ) { storage_task current; { @@ -1723,6 +1725,8 @@ void QuickSyncEncoderImpl::open_output_file(const std::string &filename) void QuickSyncEncoderImpl::encode_thread_func() { + pthread_setname_np(pthread_self(), "QS_Encode"); + int64_t last_dts = -1; int gop_start_display_frame_num = 0; for (int display_frame_num = 0; ; ++display_frame_num) { -- 2.39.2