]> git.sesse.net Git - bmusb/blobdiff - bmusb.cpp
Give all of our threads meaningful names, to aid with debugging.
[bmusb] / bmusb.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);