Fix A2DP Bluetooth audio routing, stream migration, hotplug monitoring, and q6voice teardown

This commit is contained in:
Luxferre committed 2026-11-04 15:42:58 +02:00
1 parent b2ade2dc42
commit b8dea31b59
34 files changed
+533 -155

No files matched your search

@@ -173,13 +173,37 @@ ring() {
return 0
fi
ring_rx3=$(( 56 + (SXMO_RINGVOL * 32 + 50) / 100 ))
out_dev="$(cat /tmp/sxmo_audio_out_device 2>/dev/null || printf 'Speaker')"
(
rchild=""
vhelper=""
trap '[ -n "$rchild" ] && kill -TERM "$rchild" 2>/dev/null; [ -n "$vhelper" ] && kill -TERM "$vhelper" 2>/dev/null; exit 0' INT TERM EXIT
amixer -c 0 -s >/dev/null 2>&1 <<EOF || true
if [ "$out_dev" = "Bluetooth" ]; then
amixer -c 0 cset "name='SPK DAC Switch'" 0 >/dev/null 2>&1 || true
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true
elif [ "$out_dev" = "Headphones" ]; then
ring_hp=$(( 52 + (SXMO_RINGVOL * 32 + 50) / 100 ))
amixer -c 0 -s >/dev/null 2>&1 <<EOF || true
cset "name='SPK DAC Switch'" 0
cset "name='RX3 MIX1 INP1'" 0
cset "name='RX3 Digital Volume'" 0
cset "name='EAR_S'" 0
cset "name='PRI_MI2S_RX Audio Mixer MultiMedia1'" 1
cset "name='RDAC2 MUX'" 'RX2'
cset "name='RX1 MIX1 INP1'" 'RX1'
cset "name='RX2 MIX1 INP1'" 'RX2'
cset "name='HPHL'" 'Switch'
cset "name='HPHR'" 'Switch'
cset "name='RX1 Digital Volume'" $ring_hp
cset "name='RX2 Digital Volume'" $ring_hp
EOF
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
else
amixer -c 0 -s >/dev/null 2>&1 <<EOF || true
cset "name='EAR_S'" 0
cset "name='RX1 MIX1 INP1'" 0
cset "name='PRI_MI2S_RX Audio Mixer MultiMedia1'" 1
@@ -187,22 +211,23 @@ cset "name='SPK DAC Switch'" 1
cset "name='RX3 MIX1 INP1'" 3
cset "name='RX3 Digital Volume'" $ring_rx3
EOF
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
wpctl set-mute @DEFAULT_AUDIO_SINK@ 0 >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
(
for d in 0.15 0.40; do
sleep "$d" || exit 0
should_stop_ringing && exit 0
amixer -c 0 -s >/dev/null 2>&1 <<EOF || true
(
for d in 0.15 0.40; do
sleep "$d" || exit 0
should_stop_ringing && exit 0
amixer -c 0 -s >/dev/null 2>&1 <<EOF || true
cset "name='SPK DAC Switch'" 1
cset "name='RX3 MIX1 INP1'" 3
cset "name='RX3 Digital Volume'" $ring_rx3
EOF
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
done
) &
vhelper="$!"
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
done
) &
vhelper="$!"
fi
ext="$(printf '%s' "${SXMO_RINGTONE##*.}" | tr '[:upper:]' '[:lower:]')"
play_file="$SXMO_RINGTONE"
@@ -226,8 +251,12 @@ EOF
i=0
while [ "$i" -lt "$loops" ]; do
should_stop_ringing && break
amixer -c 0 cset "name='RX3 Digital Volume'" "$ring_rx3" >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
if [ "$out_dev" = "Bluetooth" ]; then
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true
elif [ "$out_dev" != "Headphones" ]; then
amixer -c 0 cset "name='RX3 Digital Volume'" "$ring_rx3" >/dev/null 2>&1 || true
wpctl set-volume @DEFAULT_AUDIO_SINK@ 100% >/dev/null 2>&1 || true
fi
pw-play --volume=1.0 "$play_file" >/dev/null 2>&1 &
rchild="$!"
wait "$rchild" 2>/dev/null