From f9413ae56f689402e44c6dc375ce90807a9594a5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Oct 16 2023 11:26:09 +0000 Subject: Add patch for device detection for asahi linux. Add patch to avoid crash in ALSA. --- diff --git a/0001-alsa-Ignore-PCM-devices-with-udev-env-ACP_IGNORE.patch b/0001-alsa-Ignore-PCM-devices-with-udev-env-ACP_IGNORE.patch new file mode 100644 index 0000000..8d22f74 --- /dev/null +++ b/0001-alsa-Ignore-PCM-devices-with-udev-env-ACP_IGNORE.patch @@ -0,0 +1,68 @@ +From 434dfd56636c2fdb7f13cdc61eb84b72dac93146 Mon Sep 17 00:00:00 2001 +From: Hector Martin +Date: Sat, 14 Oct 2023 14:11:15 +0900 +Subject: [PATCH 1/2] alsa: Ignore PCM devices with udev env ACP_IGNORE + +When checking that a card has all of its PCM devices available, ignore +any specific device with the ACP_IGNORE udev environment variable. This +mirrors how we ignore whole cards, but specifically allows non-PipeWire +software to own specific PCM devices. + +Note that this does not actually stop PipeWire from using those +subdevices right now, we assume UCM configs take care of that. This +should probably be implemented later to ensure PipeWire always stays +away from them, but for now this fixes the issue where it refuses to +probe the entire card. + +Fixes: #3570 + +Signed-off-by: Hector Martin +--- + spa/plugins/alsa/alsa-udev.c | 24 ++++++++++++++++++++++++ + 1 file changed, 24 insertions(+) + +diff --git a/spa/plugins/alsa/alsa-udev.c b/spa/plugins/alsa/alsa-udev.c +index 3048d7363..58ff5032d 100644 +--- a/spa/plugins/alsa/alsa-udev.c ++++ b/spa/plugins/alsa/alsa-udev.c +@@ -329,6 +329,27 @@ static int get_num_compress_offload_devices(unsigned int card_nr) + return errno != 0 ? -errno : num_dev; + } + ++static int check_udev_environment(struct udev *udev, const char *devname) ++{ ++ char path[PATH_MAX]; ++ struct udev_device *dev; ++ int ret = 0; ++ ++ /* Check for ACP_IGNORE on a specific PCM device (not the whole card) */ ++ spa_scnprintf(path, sizeof(path), "/sys/class/sound/%s", devname); ++ ++ dev = udev_device_new_from_syspath(udev, path); ++ if (dev == NULL) ++ return 0; ++ ++ if (udev_device_get_property_value(dev, "ACP_IGNORE")) ++ ret = -ENXIO; ++ ++ udev_device_unref(dev); ++ ++ return ret; ++} ++ + static int check_pcm_device_availability(struct impl *this, struct card *card, + int *num_pcm_devices) + { +@@ -376,6 +397,9 @@ static int check_pcm_device_availability(struct impl *this, struct card *card, + card->card_nr, entry->d_name+3); + if (check_device_pcm_class(path) < 0) + continue; ++ /* Check udev environment */ ++ if (check_udev_environment(this->udev, path) < 0) ++ continue; + + /* Check busy status */ + spa_scnprintf(path, sizeof(path), "/proc/asound/card%u/%s", +-- +2.41.0 + diff --git a/0002-alsa-don-t-try-to-link-when-prepare-fails.patch b/0002-alsa-don-t-try-to-link-when-prepare-fails.patch new file mode 100644 index 0000000..e729512 --- /dev/null +++ b/0002-alsa-don-t-try-to-link-when-prepare-fails.patch @@ -0,0 +1,26 @@ +From d50fb6c51db80703127e240a4965026ee64cd10f Mon Sep 17 00:00:00 2001 +From: Wim Taymans +Date: Mon, 16 Oct 2023 10:32:51 +0200 +Subject: [PATCH 2/2] alsa: don't try to link when prepare fails + +--- + spa/plugins/alsa/alsa-pcm.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/spa/plugins/alsa/alsa-pcm.c b/spa/plugins/alsa/alsa-pcm.c +index fbd67cf86..df40ea9e5 100644 +--- a/spa/plugins/alsa/alsa-pcm.c ++++ b/spa/plugins/alsa/alsa-pcm.c +@@ -3042,7 +3042,8 @@ int spa_alsa_prepare(struct state *state) + + spa_list_for_each(follower, &state->followers, driver_link) { + if (follower != state && !follower->matching) { +- spa_alsa_prepare(follower); ++ if (spa_alsa_prepare(follower) < 0) ++ continue; + if (!follower->linked && state->auto_link) + do_link(state, follower); + } +-- +2.41.0 + diff --git a/pipewire.spec b/pipewire.spec index 6346777..244241a 100644 --- a/pipewire.spec +++ b/pipewire.spec @@ -9,7 +9,7 @@ %global ms_version 0.4.2 # For rpmdev-bumpspec and releng automation -%global baserelease 1 +%global baserelease 2 #global snapdate 20210107 #global gitcommit b17db2cebc1a5ab2c01851d29c05f79cd2f262bb @@ -84,6 +84,8 @@ Source1: https://gitlab.freedesktop.org/pipewire/media-session/-/archive/ %endif ## upstream patches +Patch0001: 0001-alsa-Ignore-PCM-devices-with-udev-env-ACP_IGNORE.patch +Patch0002: 0002-alsa-don-t-try-to-link-when-prepare-fails.patch ## upstreamable patches @@ -786,6 +788,10 @@ systemctl --no-reload preset --global pipewire.socket >/dev/null 2>&1 || : %endif %changelog +* Mon Oct 16 2023 Wim Taymans - 0.3.82-2 +- Add patch for device detection for asahi linux. +- Add patch to avoid crash in ALSA. + * Fri Oct 13 2023 Wim Taymans - 0.3.82-1 - Update version to 0.3.82