Skip to content

Commit 091aad4

Browse files
feat: enhance audio sink normalization for Chromium compatibility
1 parent 13da8fd commit 091aad4

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

electron-kiosk/onboarding.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,8 @@ <h1>Setup</h1>
552552
</div>
553553
<p class="hint">
554554
ALSA device string. <code>auto</code> uses the system default. Examples:
555-
<code>hw:0,0</code> (analog), <code>hw:0,3</code> (HDMI).
555+
<code>hw:0,0</code> (analog), <code>hw:0,3</code> (HDMI). Raw
556+
<code>hw:</code> values are passed through ALSA's plug layer automatically.
556557
</p>
557558
<div class="device-list hidden" id="audioDeviceList"></div>
558559
</div>

electron-kiosk/wrapper/wrapper.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ if [ -n "$KIOSK_LANG" ]; then
4747
EXTRAOPTS="$EXTRAOPTS --lang=$KIOSK_LANG"
4848
fi
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.
@@ -100,17 +114,19 @@ fi
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.
111126
if [ -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})"
114130
fi
115131

116132
exec "$SNAP/sbf-kiosk" \

0 commit comments

Comments
 (0)