From: Steinar H. Gunderson Date: Sun, 18 Feb 2018 10:13:35 +0000 (+0100) Subject: Stop trying to re-probe ALSA cards if they are not capture cards. Reduces the debug... X-Git-Tag: 1.7.0~29 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=f185dd186b7a9747331192ac55cb1f81e282cb0f Stop trying to re-probe ALSA cards if they are not capture cards. Reduces the debug spew a bit. --- diff --git a/alsa_pool.cpp b/alsa_pool.cpp index 348c623..1c9c4d3 100644 --- a/alsa_pool.cpp +++ b/alsa_pool.cpp @@ -185,19 +185,24 @@ ALSAPool::ProbeResult ALSAPool::probe_device_once(unsigned card_index, unsigned } unique_ptr 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