Open tmigone opened 2 years ago
[tmigone] This issue has attached support thread https://jel.ly.fish/23fd0d70-7d8e-446e-a4d5-891f1f705c80
I'd guess this could be kernel or alsa-lib issue so please re-test. The error reported looks almost like if kernel alsa layer created /dev/snd/
entry (which is getting picked by pulseaudio udev monitoring routine) before kernel alsa driver completed all things required for alsa-lib to actually use the device successfully - this should never happen.
I know this has been ages, but was any progress made on this? That jellyfish URL seems to be invalid.
We're having issues with a container starting up and even when the USB device is plugged in, it doesn't always recognize it in time. Even when it does, no hot swapping seems to work. When this occurs, after boot, there's no sound card discovered and no way to fix it without restarting the service, which starts the process over and may still not fix it.
although we first found about this issue when testing DACs, I also have a similar problem with the audio jack. I could replicate this with a minimal balena-sound instance in standalone and with spotify. We are using the .
What I realized is that on a different model of hardware, flashed with the same balena OS image (generic x64 GPT version), the alsa_output.hda-intel.analog-stereo
sink is always visible, regardless of the jack being connected or not and the hot plugging works smoothly.
However, on the hardware showing the issue, the sink appears and disappears following the plugged cable, but if the cable was not plugged at startup, the sink would stain in IDLE state (with a different ID, which probably explains the issue)
List sinks after boot with cable connected
bash-5.1# pactl list sinks
Sink #0
State: RUNNING
Name: alsa_output.hda-intel.analog-stereo
Description: Built-in Audio Analog Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 6
Mute: no
Volume: front-left: 49152 / 75% / -7.50 dB, front-right: 49152 / 75% / -7.50 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: alsa_output.hda-intel.analog-stereo.monitor
Latency: 46484 usec, configured 66666 usec
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC269VB Analog"
alsa.id = "ALC269VB Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "HDA Intel PCH"
alsa.long_card_name = "HDA Intel PCH at 0x91210000 irq 133"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:0e.0"
sysfs.path = "/devices/pci0000:00/0000:00:0e.0/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.product.id = "5a98"
device.form_factor = "internal"
device.string = "front:0"
device.buffering.buffer_size = "352800"
device.buffering.fragment_size = "176400"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "Built-in Audio Analog Stereo"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
Ports:
analog-output-speaker: Speakers (type: Speaker, priority: 10000, available)
Active Port: analog-output-speaker
Formats:
pcm
Sink #1
State: IDLE
Name: balena-sound.input
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 21
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: balena-sound.input.monitor
Latency: 29566 usec, configured 66666 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
Sink #2
State: RUNNING
Name: balena-sound.output
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 22
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: balena-sound.output.monitor
Latency: 44743 usec, configured 66666 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
Sink #3
State: SUSPENDED
Name: snapcast
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 23
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: snapcast.monitor
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
List sinks after unplugging the cable
bash-5.1# pactl list sinks
Sink #1
State: RUNNING
Name: balena-sound.input
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 21
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: balena-sound.input.monitor
Latency: 49041 usec, configured 66666 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
Sink #2
State: RUNNING
Name: balena-sound.output
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 22
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: balena-sound.output.monitor
Latency: 63825 usec, configured 66666 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
Sink #3
State: SUSPENDED
Name: snapcast
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 23
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: snapcast.monitor
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
List sinks after plugging again the cable
bash-5.1# pactl list sinks
Sink #1
State: RUNNING
Name: balena-sound.input
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 21
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: balena-sound.input.monitor
Latency: 25150 usec, configured 66666 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
Sink #2
State: RUNNING
Name: balena-sound.output
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 22
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: balena-sound.output.monitor
Latency: 65971 usec, configured 66666 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
Sink #3
State: SUSPENDED
Name: snapcast
Description: Null Output
Driver: module-null-sink.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 23
Mute: no
Volume: front-left: 65536 / 100% / 0.00 dB, front-right: 65536 / 100% / 0.00 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: snapcast.monitor
Latency: 0 usec, configured 0 usec
Flags: DECIBEL_VOLUME LATENCY SET_FORMATS
Properties:
device.description = "Null Output"
device.class = "abstract"
device.icon_name = "audio-card"
Formats:
pcm
Sink #4
State: IDLE
Name: alsa_output.hda-intel.analog-stereo
Description: Built-in Audio Analog Stereo
Driver: module-alsa-card.c
Sample Specification: s16le 2ch 44100Hz
Channel Map: front-left,front-right
Owner Module: 6
Mute: no
Volume: front-left: 49152 / 75% / -7.50 dB, front-right: 49152 / 75% / -7.50 dB
balance 0.00
Base Volume: 65536 / 100% / 0.00 dB
Monitor Source: alsa_output.hda-intel.analog-stereo.monitor
Latency: 67121 usec, configured 66666 usec
Flags: HARDWARE HW_MUTE_CTRL HW_VOLUME_CTRL DECIBEL_VOLUME LATENCY
Properties:
alsa.resolution_bits = "16"
device.api = "alsa"
device.class = "sound"
alsa.class = "generic"
alsa.subclass = "generic-mix"
alsa.name = "ALC269VB Analog"
alsa.id = "ALC269VB Analog"
alsa.subdevice = "0"
alsa.subdevice_name = "subdevice #0"
alsa.device = "0"
alsa.card = "0"
alsa.card_name = "HDA Intel PCH"
alsa.long_card_name = "HDA Intel PCH at 0x91210000 irq 133"
alsa.driver_name = "snd_hda_intel"
device.bus_path = "pci-0000:00:0e.0"
sysfs.path = "/devices/pci0000:00/0000:00:0e.0/sound/card0"
device.bus = "pci"
device.vendor.id = "8086"
device.product.id = "5a98"
device.form_factor = "internal"
device.string = "front:0"
device.buffering.buffer_size = "352800"
device.buffering.fragment_size = "176400"
device.access_mode = "mmap+timer"
device.profile.name = "analog-stereo"
device.profile.description = "Analog Stereo"
device.description = "Built-in Audio Analog Stereo"
module-udev-detect.discovered = "1"
device.icon_name = "audio-card-pci"
Ports:
analog-output-speaker: Speakers (type: Speaker, priority: 10000, available)
Active Port: analog-output-speaker
Formats:
pcm
We're currently working around this issue by using pactl
to manually load the module-alsa-card
for the device when it is connected and unload it upon disconnection. This loading and unloading process is triggered by udev
.
Additionally, the 78-sound-card.rules
file provides guidance on which events to filter in udev
, so I recommend checking its comments for further insights.
To replicate
Running
udev monitor
oraplay -l
will show that both udev and ALSA are picking up the sound card. However runningpactl list sinks
will yield no result. PulseAudio is ignoring the udev events it seems.If you invert the order of operations however hotplugging works as intended:
This might be related to how systemd ALSA rules are handled, and how PulseAudio interacts with that (seems a bit sketchy?). Some references here for further investigation: