]> git.sesse.net Git - bmusb/commitdiff
Give all of our threads meaningful names, to aid with debugging.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 25 Jan 2017 18:18:49 +0000 (19:18 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Wed, 25 Jan 2017 18:18:49 +0000 (19:18 +0100)
bmusb.cpp
bmusb/fake_capture.h
fake_capture.cpp

index de895d9240a858243f532c6a52ae03d59649b3d4..0c3fb551570188ba74e674d9e181f5ca3514b66b 100644 (file)
--- a/bmusb.cpp
+++ b/bmusb.cpp
@@ -13,6 +13,7 @@
 #include <libusb.h>
 #include <unistd.h>
 #include <netinet/in.h>
+#include <pthread.h>
 #include <sched.h>
 #include <stdint.h>
 #include <stdio.h>
@@ -289,6 +290,10 @@ void dump_audio_block(uint8_t *audio_start, size_t audio_len)
 
 void BMUSBCapture::dequeue_thread_func()
 {
+       char thread_name[16];
+       snprintf(thread_name, sizeof(thread_name), "bmusb_dequeue_%d", card_index);
+       pthread_setname_np(pthread_self(), thread_name);
+
        if (has_dequeue_callbacks) {
                dequeue_init_callback();
        }
@@ -886,6 +891,7 @@ void BMUSBCapture::usb_thread_func()
        if (sched_setscheduler(0, SCHED_RR, &param) == -1) {
                printf("couldn't set realtime priority for USB thread: %s\n", strerror(errno));
        }
+       pthread_setname_np(pthread_self(), "bmusb_usb_drv");
        while (!should_quit) {
                timeval sec { 1, 0 };
                int rc = libusb_handle_events_timeout(nullptr, &sec);
index ad432f7d96d5e4a5bb77919dc01b903034fe9869..06f7ef23dd7196278bd1da981b1b09d0cec60fc7 100644 (file)
@@ -82,6 +82,7 @@ private:
        void make_tone(int32_t *out, unsigned num_stereo_samples, unsigned num_channels);
 
        unsigned width, height, fps, audio_sample_frequency;
+       int card_index;
        uint8_t y, cb, cr;
 
        // sin(2 * pi * f / F) and similar for cos. Used for fast sine generation.
index fbcfeddbf14bffc9b020a41772db44eb0e629561..29b06b100d016d49543114c0056a6c31e4bf05dd 100644 (file)
@@ -4,6 +4,7 @@
 #include "bmusb/fake_capture.h"
 
 #include <assert.h>
+#include <pthread.h>
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -89,7 +90,7 @@ void memset4(uint8_t *s, const uint8_t c[4], size_t n)
 }  // namespace
 
 FakeCapture::FakeCapture(unsigned width, unsigned height, unsigned fps, unsigned audio_sample_frequency, int card_index, bool has_audio)
-       : width(width), height(height), fps(fps), audio_sample_frequency(audio_sample_frequency)
+       : width(width), height(height), fps(fps), audio_sample_frequency(audio_sample_frequency), card_index(card_index)
 {
        char buf[256];
        snprintf(buf, sizeof(buf), "Fake card %d", card_index + 1);
@@ -201,6 +202,10 @@ bool timespec_less_than(const timespec &a, const timespec &b)
 
 void FakeCapture::producer_thread_func()
 {
+       char thread_name[16];
+       snprintf(thread_name, sizeof(thread_name), "FakeCapture_%d", card_index);
+       pthread_setname_np(pthread_self(), thread_name);
+
        uint16_t timecode = 0;
 
        if (has_dequeue_callbacks) {