spa/alsa-udev: ignore all errors in card busy check

If card busy check fails due to error, just log info message and
consider the card not busy.

For kernels with CONFIG_SND_PROCFS=n, /proc/asound is not present, and
we have to handle that.  It's also better to fail open here, rather than
end up with missing devices.
This commit is contained in:
Pauli Virtanen 2022-02-06 20:02:08 +02:00
parent fa484f346e
commit bae2cc0a6e

View file

@ -286,8 +286,8 @@ static int get_num_pcm_devices(unsigned int card_id)
continue; continue;
res = check_device_pcm_class(entry->d_name); res = check_device_pcm_class(entry->d_name);
if (res == 0 || res == -ENOENT) { if (res != -ENXIO) {
/* count device also if sysfs status file not there */ /* count device also if sysfs status file not accessible */
++num_dev; ++num_dev;
} }
} }
@ -325,11 +325,13 @@ static int check_device_available(struct impl *this, struct device *device, int
* don't want to actually open any devices using alsa-lib (generates uncontrolled * don't want to actually open any devices using alsa-lib (generates uncontrolled
* number of inotify events), or replicate its subdevice logic. * number of inotify events), or replicate its subdevice logic.
* *
* The pcmXX directories do not exist if kernel is compiled with * The /proc/asound directory might not exist if kernel is compiled with
* CONFIG_SND_VERBOSE_PROCFS=n. In that case, the busy check always * CONFIG_SND_PROCFS=n, and the pcmXX directories may be missing if compiled
* succeeds. * with CONFIG_SND_VERBOSE_PROCFS=n. In those cases, the busy check always succeeds.
*/ */
res = 0;
spa_scnprintf(path, sizeof(path), "/proc/asound/card%u", (unsigned int)device->id); spa_scnprintf(path, sizeof(path), "/proc/asound/card%u", (unsigned int)device->id);
if ((card = opendir(path)) == NULL) if ((card = opendir(path)) == NULL)
@ -369,7 +371,7 @@ static int check_device_available(struct impl *this, struct device *device, int
if (!spa_strstartswith(buf, "closed")) { if (!spa_strstartswith(buf, "closed")) {
spa_log_debug(this->log, "card %u pcm device %s busy", spa_log_debug(this->log, "card %u pcm device %s busy",
(unsigned int)device->id, entry->d_name); (unsigned int)device->id, entry->d_name);
errno = EBUSY; res = -EBUSY;
goto done; goto done;
} }
spa_log_debug(this->log, "card %u pcm device %s free", spa_log_debug(this->log, "card %u pcm device %s free",
@ -385,7 +387,10 @@ static int check_device_available(struct impl *this, struct device *device, int
goto done; goto done;
done: done:
res = -errno; if (errno != 0) {
spa_log_info(this->log, "card %u: failed to find busy status (%s)",
(unsigned int)device->id, spa_strerror(-errno));
}
if (card) if (card)
closedir(card); closedir(card);
if (pcm) if (pcm)