X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=alsa_pool.cpp;h=348c6232303ab561d3a4039ca69932261bd3e8bc;hb=40d316173fde0830a1727d78604ad12e6e5dec01;hp=0a7da5946292a45291bae50cf9c21a373596e177;hpb=d02079ef22fb3ef05ced8592b2dbf28bb5b289b3;p=nageru diff --git a/alsa_pool.cpp b/alsa_pool.cpp index 0a7da59..348c623 100644 --- a/alsa_pool.cpp +++ b/alsa_pool.cpp @@ -1,16 +1,22 @@ #include "alsa_pool.h" -#include -#include -#include +#include #include +#include #include +#include +#include +#include #include #include #include #include #include +#include +#include +#include #include +#include #include "alsa_input.h" #include "audio_mixer.h" @@ -36,7 +42,10 @@ ALSAPool::~ALSAPool() } should_quit = true; const uint64_t one = 1; - write(should_quit_fd, &one, sizeof(one)); + if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) { + perror("write(should_quit_fd)"); + exit(1); + } inotify_thread.join(); while (retry_threads_running > 0) { @@ -126,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); @@ -280,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()"); @@ -378,7 +393,7 @@ void ALSAPool::reset_device(unsigned index) inputs[index].reset(); } else { // TODO: Put on a background thread instead of locking? - auto callback = bind(&AudioMixer::add_audio, global_audio_mixer, DeviceSpec{InputSourceType::ALSA_INPUT, index}, _1, _2, _3, _4); + auto callback = bind(&AudioMixer::add_audio, global_audio_mixer, DeviceSpec{InputSourceType::ALSA_INPUT, index}, _1, _2, _3, _4, _5); inputs[index].reset(new ALSAInput(device->address.c_str(), OUTPUT_FREQUENCY, device->num_channels, callback, this, index)); inputs[index]->start_capture_thread(); }