@@ -47,6 +47,20 @@ if [ -n "$KIOSK_LANG" ]; then
4747 EXTRAOPTS=" $EXTRAOPTS --lang=$KIOSK_LANG "
4848fi
4949
50+ normalize_audio_sink_for_chromium () {
51+ case " $1 " in
52+ hw:* )
53+ # Chromium may open the device with stream params that raw `hw:` nodes do
54+ # not accept, such as mono output on HDMI sinks. `plughw:` keeps the same
55+ # target card/device while letting ALSA adapt channel count/format.
56+ printf ' plughw:%s\n' " ${1# hw: } "
57+ ;;
58+ * )
59+ printf ' %s\n' " $1 "
60+ ;;
61+ esac
62+ }
63+
5064# --- ALSA audio initialisation ---
5165# The sound card boots with Master muted at 0%. We must unmute and set volume
5266# before Electron starts, otherwise there is no sound even though the hardware works.
100114} 2> /dev/null || echo " Audio: amixer not available — is the 'alsa' plug connected?"
101115
102116# Select ALSA output device if explicitly configured.
103- # 'auto' uses the ALSA default (hw:0,0 = analog on most Intel HDA systems) .
117+ # 'auto' uses the ALSA default device and mixer routing .
104118# Available devices: run aplay -l from inside the snap:
105119# sudo snap run --shell sbf-kiosk.daemon -c "aplay -l"
106120#
107121# Examples:
108122# snap set sbf-kiosk audio-sink=hw:0,0 # ALC3228 Analog
109123# snap set sbf-kiosk audio-sink=hw:0,3 # HDMI 0
110124# snap set sbf-kiosk audio-sink=hw:0,7 # HDMI 1
125+ # Raw `hw:` values are normalized to `plughw:` for Chromium compatibility.
111126if [ -n " $AUDIO_SINK " ] && [ " $AUDIO_SINK " != " auto" ]; then
112- EXTRAOPTS=" $EXTRAOPTS --alsa-output-device=${AUDIO_SINK} "
113- echo " Audio: ALSA device → ${AUDIO_SINK} "
127+ CHROMIUM_AUDIO_SINK=" $( normalize_audio_sink_for_chromium " $AUDIO_SINK " ) "
128+ EXTRAOPTS=" $EXTRAOPTS --alsa-output-device=${CHROMIUM_AUDIO_SINK} "
129+ echo " Audio: ALSA device → ${AUDIO_SINK} (Chromium uses ${CHROMIUM_AUDIO_SINK} )"
114130fi
115131
116132exec " $SNAP /sbf-kiosk" \
0 commit comments