#include "alsa_pool.h"
-#include <alsa/control.h>
-#include <alsa/error.h>
-#include <alsa/pcm.h>
+#include <alsa/asoundlib.h>
#include <assert.h>
+#include <errno.h>
#include <limits.h>
+#include <pthread.h>
+#include <poll.h>
+#include <stdint.h>
#include <stdio.h>
#include <sys/eventfd.h>
#include <sys/inotify.h>
#include <unistd.h>
#include <algorithm>
+#include <chrono>
+#include <functional>
+#include <iterator>
#include <memory>
+#include <ratio>
#include "alsa_input.h"
#include "audio_mixer.h"
}
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) {
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);
void ALSAPool::inotify_thread_func()
{
+ pthread_setname_np(pthread_self(), "ALSA_Hotplug");
+
int inotify_fd = inotify_init();
if (inotify_fd == -1) {
perror("inotify_init()");
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();
}