]> git.sesse.net Git - nageru/commitdiff
Stop trying to re-probe ALSA cards if they are not capture cards. Reduces the debug...
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Feb 2018 10:13:35 +0000 (11:13 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 18 Feb 2018 15:56:42 +0000 (16:56 +0100)
alsa_pool.cpp

index 348c6232303ab561d3a4039ca69932261bd3e8bc..1c9c4d389a46fc5246a4693439fd9f09b77bfdfb 100644 (file)
@@ -185,19 +185,24 @@ ALSAPool::ProbeResult ALSAPool::probe_device_once(unsigned card_index, unsigned
        }
        unique_ptr<snd_ctl_t, decltype(snd_ctl_close)*> ctl_closer(ctl, snd_ctl_close);
 
+       snprintf(address, sizeof(address), "hw:%d,%d", card_index, dev_index);
+
        snd_pcm_info_t *pcm_info;
        snd_pcm_info_alloca(&pcm_info);
        snd_pcm_info_set_device(pcm_info, dev_index);
        snd_pcm_info_set_subdevice(pcm_info, 0);
        snd_pcm_info_set_stream(pcm_info, SND_PCM_STREAM_CAPTURE);
-       if (snd_ctl_pcm_info(ctl, pcm_info) < 0) {
+       err = snd_ctl_pcm_info(ctl, pcm_info);
+       if (err == -ENOENT) {
+               // Not a capture card.
+               return ALSAPool::ProbeResult::FAILURE;
+       }
+       if (err < 0) {
                // Not available for capture.
-               printf("%s: Not available for capture.\n", address);
+               printf("%s: Not available for capture. %d\n", address, err);
                return ALSAPool::ProbeResult::DEFER;
        }
 
-       snprintf(address, sizeof(address), "hw:%d,%d", card_index, dev_index);
-
        unsigned num_channels = 0;
 
        // Find all channel maps for this device, and pick out the one