]> git.sesse.net Git - nageru/blobdiff - nageru/alsa_pool.cpp
When the delay analyzer wants audio from an ALSA card, temporarily auto-enable captur...
[nageru] / nageru / alsa_pool.cpp
index 978f236886256e529e448c6dbcd37c53be951bfc..4e12bb75349750d57d2e2ff1b72e43a1def841ce 100644 (file)
@@ -44,7 +44,7 @@ ALSAPool::~ALSAPool()
        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();
 
@@ -53,11 +53,13 @@ ALSAPool::~ALSAPool()
        }
 }
 
-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;
 }
@@ -77,6 +79,16 @@ void ALSAPool::release_device(unsigned index)
        }
 }
 
+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.