Repository navigation
libudev-zero: let PipeWire find the sound cards #31249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dangowrt
wants to merge
1
commit into
openwrt:master
Choose a base branch
from
dangowrt:libudev-zero-sound-initialized
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
libs/libudev-zero/patches/001-udev_device-mark-sound-cards-as-initialised.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| From 584578c0deac728780108a6b80ecda4e6e608cca Mon Sep 17 00:00:00 2001 | ||
| From: Daniel Golle <daniel@makrotopia.org> | ||
| Date: Wed, 9 Sep 2026 02:09:58 +0100 | ||
| Subject: [PATCH] udev_device: mark sound cards as initialised | ||
|
|
||
| PipeWire's ALSA udev plugin skips every sound card whose udev device | ||
| lacks the SOUND_INITIALIZED property, which udev's 78-sound-card rule | ||
| sets once alsactl has restored the card. Without udev nothing sets it, | ||
| so PipeWire never sees a card and offers only a dummy output. Add the | ||
| property to sound card devices the way ID_INPUT is synthesised for | ||
| input devices. | ||
|
|
||
| Signed-off-by: Daniel Golle <daniel@makrotopia.org> | ||
| --- | ||
| udev_device.c | 23 +++++++++++++++++++++++ | ||
| 1 file changed, 23 insertions(+) | ||
|
|
||
| --- a/udev_device.c | ||
| +++ b/udev_device.c | ||
| @@ -540,6 +540,27 @@ static void set_properties_from_props(st | ||
| udev_list_entry_add(&udev_device->properties, "ID_PATH", id, 0); | ||
| } | ||
|
|
||
| +static void set_properties_from_sound(struct udev_device *udev_device) | ||
| +{ | ||
| + const char *devpath, *subsystem, *name; | ||
| + | ||
| + subsystem = udev_device_get_subsystem(udev_device); | ||
| + devpath = udev_device_get_devpath(udev_device); | ||
| + | ||
| + if (!subsystem || !devpath || strcmp(subsystem, "sound") != 0) { | ||
| + return; | ||
| + } | ||
| + | ||
| + name = strrchr(devpath, '/'); | ||
| + | ||
| + if (!name || strncmp(name, "/card", 5) != 0) { | ||
| + return; | ||
| + } | ||
| + | ||
| + /* udev sets this once alsactl has run; nothing else can here */ | ||
| + udev_list_entry_add(&udev_device->properties, "SOUND_INITIALIZED", "1", 0); | ||
| +} | ||
| + | ||
| struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath) | ||
| { | ||
| char *subsystem, *driver, *sysname; | ||
| @@ -593,6 +614,7 @@ struct udev_device *udev_device_new_from | ||
|
|
||
| set_properties_from_evdev(udev_device); | ||
| set_properties_from_props(udev_device); | ||
| + set_properties_from_sound(udev_device); | ||
|
|
||
| free(driver); | ||
| free(subsystem); | ||
| @@ -712,6 +734,7 @@ struct udev_device *udev_device_new_from | ||
|
|
||
| set_properties_from_props(udev_device); | ||
| set_properties_from_evdev(udev_device); | ||
| + set_properties_from_sound(udev_device); | ||
| return udev_device; | ||
| } | ||
|
|
54 changes: 54 additions & 0 deletions
54
libs/libudev-zero/patches/002-udev_enumerate-scan-the-classes-of-matched-subsystems.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| From a15d506dbefb531366ad605c44686043de30fb3e Mon Sep 17 00:00:00 2001 | ||
| From: Daniel Golle <daniel@makrotopia.org> | ||
| Date: Wed, 9 Sep 2026 02:14:14 +0100 | ||
| Subject: [PATCH] udev_enumerate: scan the classes of matched subsystems | ||
|
|
||
| /sys/dev lists only devices that own a device node, so an enumeration | ||
| never returns class members without one, such as the sound card | ||
| objects PipeWire's ALSA plugin looks for: it sees the control and PCM | ||
| nodes but never a card. For each subsystem the caller matched, also | ||
| scan /sys/class/<subsystem>, skipping syspaths already listed. | ||
|
|
||
| Signed-off-by: Daniel Golle <daniel@makrotopia.org> | ||
| --- | ||
| udev_enumerate.c | 15 ++++++++++++++- | ||
| 1 file changed, 14 insertions(+), 1 deletion(-) | ||
|
|
||
| --- a/udev_enumerate.c | ||
| +++ b/udev_enumerate.c | ||
| @@ -241,7 +241,9 @@ static void add_device(struct udev_enume | ||
| return; | ||
| } | ||
|
|
||
| - udev_list_entry_add(&udev_enumerate->devices, udev_device_get_syspath(udev_device), NULL, 0); | ||
| + if (!udev_list_entry_get_by_name(&udev_enumerate->devices, udev_device_get_syspath(udev_device))) { | ||
| + udev_list_entry_add(&udev_enumerate->devices, udev_device_get_syspath(udev_device), NULL, 0); | ||
| + } | ||
|
|
||
| udev_device_unref(udev_device); | ||
| } | ||
| @@ -279,6 +281,8 @@ static int scan_devices(struct udev_enum | ||
| int udev_enumerate_scan_devices(struct udev_enumerate *udev_enumerate) | ||
| { | ||
| const char *path[] = { "/sys/dev/block", "/sys/dev/char", NULL }; | ||
| + struct udev_list_entry *list_entry; | ||
| + char class_path[PATH_MAX]; | ||
| int i; | ||
|
|
||
| if (!udev_enumerate) { | ||
| @@ -291,6 +295,15 @@ int udev_enumerate_scan_devices(struct u | ||
| } | ||
| } | ||
|
|
||
| + /* /sys/dev only lists devices with a node; a matched class may hold more */ | ||
| + list_entry = udev_list_entry_get_next(&udev_enumerate->subsystem_match); | ||
| + | ||
| + while (list_entry) { | ||
| + snprintf(class_path, sizeof(class_path), "/sys/class/%s", udev_list_entry_get_name(list_entry)); | ||
| + scan_devices(udev_enumerate, class_path); | ||
| + list_entry = udev_list_entry_get_next(list_entry); | ||
| + } | ||
| + | ||
| return 0; | ||
| } | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Subsystem matches are
fnmatch()patterns (filter_subsystem()at udev_enumerate.c:105-111), so a glob match such assound*builds a literal/sys/class/sound*path,scandir()fails silently, and node-less class members are still missed. Optional: scan/sys/classandfnmatch()each entry against the pattern instead. PipeWire's literalsoundmatch is unaffected, so this does not block the merge.Generated by Claude Code