[pulseaudio-discuss] Using PULSE_NAME to override USB audio card names

Lucas Rangit Magasweran lucasrangit at gmail.com
Wed Sep 6 21:34:30 UTC 2017


Hello devs,

Is it okay to use PULSE_NAME in a udev rule to override the card name
used by PulseAudio? PULSE_NAME is used by
`module-udev-detect.c:card_change()` but is undocumented.

I found this solution when I needed a way to override the USB audio
card name created by udev (e.g. ID_ID). Because it contains the USB
device serial number in the name it is not possible to write a general
`pacmd <card_name>` that works for all units.

Below is the udev rule I created. It works but I'm wondering if there
are side effects to no longer having unique card names or not having
the ID_ID udev property. I tested having multiple identical (except
the serial number) USB sound cards attached and they work
simultaneously.

$ cat /lib/udev/rules.d/79-pulseaudio-usb-rename.rules
SUBSYSTEM!="sound", GOTO="sound_end"
ACTION!="add|change", GOTO="sound_end"

KERNEL!="card*", GOTO="sound_end"

IMPORT{builtin}="hwdb"
SUBSYSTEMS=="usb", IMPORT{builtin}="usb_id"

# Remove serial number so that names are not unit specific.
# PULSE_NAME overrides the card name used by PulseAudio.
ENV{ID_MODEL}=="?*", ENV{ID_VENDOR}=="?*",
ENV{ID_USB_INTERFACE_NUM}=="?*",
ENV{PULSE_NAME}="$env{ID_BUS}-$env{ID_VENDOR}_$env{ID_MODEL}-$env{ID_USB_INTERFACE_NUM}",
GOTO="sound_end"
ENV{ID_MODEL}=="?*", ENV{ID_VENDOR}=="?*",
ENV{ID_USB_INTERFACE_NUM}=="",
ENV{PULSE_NAME}="$env{ID_BUS}-$env{ID_VENDOR}_$env{ID_MODEL}",
GOTO="sound_end"

LABEL="sound_end"

Thanks,

Lucas


More information about the pulseaudio-discuss mailing list