const uint64_t one = 1;
if (write(should_quit_fd, &one, sizeof(one)) != sizeof(one)) {
perror("write(should_quit_fd)");
- exit(1);
+ abort();
}
inotify_thread.join();
}
}
-std::vector<ALSAPool::Device> ALSAPool::get_devices()
+std::vector<ALSAPool::Device> ALSAPool::get_devices(bool hold_devices)
{
lock_guard<mutex> lock(mu);
- for (Device &device : devices) {
- device.held = true;
+ if (hold_devices) {
+ for (Device &device : devices) {
+ device.held = true;
+ }
}
return devices;
}
}
}
+bool ALSAPool::device_is_held(unsigned index)
+{
+ lock_guard<mutex> lock(mu);
+ if (index < devices.size()) {
+ return devices[index].held;
+ } else {
+ return false;
+ }
+}
+
void ALSAPool::enumerate_devices()
{
// Enumerate all cards.