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