Optimize Bluetooth volume control latency and fix WirePlumber startup race
This commit is contained in:
1 parent
85bf18ec32
commit
c7cdde6734
30 files changed
+514
-185
No files matched your search
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=low-level multimedia framework - capture and playback for both audio and video
|
||||
After=pipewire
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/usr/bin/pipewire -c pipewire-pulse.conf
|
||||
RestartSec=1s
|
||||
@@ -0,0 +1,8 @@
|
||||
[Unit]
|
||||
Description=low-level multimedia framework - capture and playback for both audio and video
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/usr/bin/pipewire
|
||||
RestartSec=1s
|
||||
@@ -0,0 +1,9 @@
|
||||
[Unit]
|
||||
Description=Session / policy manager implementation for PipeWire
|
||||
After=pipewire
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/usr/bin/wireplumber
|
||||
RestartSec=1s
|
||||
@@ -182,8 +182,8 @@ ring() {
|
||||
|
||||
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
|
||||
pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true
|
||||
pactl set-sink-volume @DEFAULT_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
|
||||
@@ -200,8 +200,8 @@ 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
|
||||
pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true
|
||||
pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true
|
||||
else
|
||||
amixer -c 0 -s >/dev/null 2>&1 <<EOF || true
|
||||
cset "name='EAR_S'" 0
|
||||
@@ -211,8 +211,8 @@ 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
|
||||
pactl set-sink-mute @DEFAULT_SINK@ 0 >/dev/null 2>&1 || true
|
||||
pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true
|
||||
|
||||
(
|
||||
for d in 0.15 0.40; do
|
||||
@@ -223,7 +223,7 @@ 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
|
||||
pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true
|
||||
done
|
||||
) &
|
||||
vhelper="$!"
|
||||
@@ -252,10 +252,10 @@ EOF
|
||||
while [ "$i" -lt "$loops" ]; do
|
||||
should_stop_ringing && break
|
||||
if [ "$out_dev" = "Bluetooth" ]; then
|
||||
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${SXMO_RINGVOL}%" >/dev/null 2>&1 || true
|
||||
pactl set-sink-volume @DEFAULT_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
|
||||
pactl set-sink-volume @DEFAULT_SINK@ 100% >/dev/null 2>&1 || true
|
||||
fi
|
||||
pw-play --volume=1.0 "$play_file" >/dev/null 2>&1 &
|
||||
rchild="$!"
|
||||
|
||||
@@ -37,8 +37,15 @@ if [ -z "$SXMO_NO_AUDIO" ]; then
|
||||
if [ "$(command -v pulseaudio)" ]; then
|
||||
superctl start pulseaudio
|
||||
elif [ "$(command -v pipewire)" ]; then
|
||||
# pipewire-pulse will start pipewire
|
||||
pidof -s pipewire >/dev/null 2>&1 || superctl start pipewire-pulse
|
||||
if ! pidof -s pipewire >/dev/null 2>&1; then
|
||||
superctl start pipewire
|
||||
pw_wait=0
|
||||
while [ ! -S "${XDG_RUNTIME_DIR:-/run/user/10000}/pipewire-0" ] && [ "$pw_wait" -lt 30 ]; do
|
||||
sleep 0.1
|
||||
pw_wait=$((pw_wait + 1))
|
||||
done
|
||||
fi
|
||||
superctl start pipewire-pulse
|
||||
pidof -s wireplumber >/dev/null 2>&1 || superctl start wireplumber
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -442,35 +442,60 @@ set_notifications() {
|
||||
|
||||
set_volume() {
|
||||
VOLCMP=""
|
||||
|
||||
if sxmo_audio.sh mic ismuted; then
|
||||
_cfg_dir="${XDG_CONFIG_HOME:-$HOME/.config}/sxmo"
|
||||
_mic_m=0
|
||||
[ -r /tmp/sxmo_mic_muted ] && read -r _mic_m < /tmp/sxmo_mic_muted 2>/dev/null || _mic_m=0
|
||||
if [ "$_mic_m" = "1" ]; then
|
||||
VOLCMP="$icon_mmc"
|
||||
else
|
||||
case "$(sxmo_audio.sh device getinput 2>/dev/null)" in
|
||||
_in_dev=""
|
||||
[ -r /tmp/sxmo_audio_in_device ] && read -r _in_dev < /tmp/sxmo_audio_in_device 2>/dev/null || _in_dev=""
|
||||
case "$_in_dev" in
|
||||
*Headset*)
|
||||
VOLCMP="$icon_hst"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if sxmo_audio.sh vol ismuted; then
|
||||
_out_m=0
|
||||
[ -r /tmp/sxmo_out_muted ] && read -r _out_m < /tmp/sxmo_out_muted 2>/dev/null || _out_m=0
|
||||
_out_dev=""
|
||||
[ -r /tmp/sxmo_audio_out_device ] && read -r _out_dev < /tmp/sxmo_audio_out_device 2>/dev/null || _out_dev=""
|
||||
if [ -z "$_out_dev" ] && [ -r "$_cfg_dir/audio_out_device" ]; then
|
||||
read -r _out_dev < "$_cfg_dir/audio_out_device" 2>/dev/null || _out_dev=""
|
||||
fi
|
||||
case "$_out_dev" in
|
||||
*[Bb]luetooth*|*[Bb]luez*)
|
||||
_vf="$_cfg_dir/bluetooth_vol"
|
||||
_defv=80
|
||||
_dev_icon="$icon_hdp"
|
||||
;;
|
||||
*[Hh]eadphone*|*[Hh]eadset*)
|
||||
_vf="$_cfg_dir/headphones_vol"
|
||||
_defv=80
|
||||
_dev_icon="$icon_hdp"
|
||||
;;
|
||||
*[Ee]arpiece*)
|
||||
_vf="$_cfg_dir/earpiece_vol"
|
||||
_defv=85
|
||||
_dev_icon="$icon_ear"
|
||||
;;
|
||||
*)
|
||||
_vf="$_cfg_dir/speaker_vol"
|
||||
_defv=85
|
||||
_dev_icon=""
|
||||
;;
|
||||
esac
|
||||
VOL="$_defv"
|
||||
[ -r "$_vf" ] && read -r VOL < "$_vf" 2>/dev/null || VOL="$_defv"
|
||||
case "$VOL" in
|
||||
''|*[!0-9-]*) VOL="$_defv" ;;
|
||||
esac
|
||||
|
||||
if [ "$_out_m" = "1" ] || [ "$VOL" -le 0 ]; then
|
||||
VOLCMP="${VOLCMP:+$VOLCMP }$icon_mut"
|
||||
else
|
||||
case "$(sxmo_audio.sh device get 2>/dev/null)" in
|
||||
*Speaker*|"")
|
||||
# nothing for default or pulse devices
|
||||
;;
|
||||
*Headphone*)
|
||||
VOLCMP="${VOLCMP:+$VOLCMP }$icon_hdp"
|
||||
;;
|
||||
*Earpiece*)
|
||||
VOLCMP="${VOLCMP:+$VOLCMP }$icon_ear"
|
||||
;;
|
||||
esac
|
||||
VOL="$(sxmo_audio.sh vol get 2>/dev/null)"
|
||||
case "$VOL" in
|
||||
''|*[!0-9]*) VOL=0 ;;
|
||||
esac
|
||||
[ -n "$_dev_icon" ] && VOLCMP="${VOLCMP:+$VOLCMP }$_dev_icon"
|
||||
if [ "$VOL" -gt 66 ]; then
|
||||
VOLCMP="${VOLCMP:+$VOLCMP }$icon_spk"
|
||||
elif [ "$VOL" -gt 33 ]; then
|
||||
|
||||
@@ -1,8 +1,27 @@
|
||||
wireplumber.profiles = {
|
||||
main = {
|
||||
hardware.video-capture = disabled
|
||||
monitor.bluez-midi = disabled
|
||||
support.logind = disabled
|
||||
monitor.bluez.seat-monitoring = disabled
|
||||
support.reserve-device = disabled
|
||||
monitor.alsa.reserve-device = disabled
|
||||
support.portal-permissionstore = disabled
|
||||
script.client.access-portal = disabled
|
||||
}
|
||||
}
|
||||
|
||||
wireplumber.settings = {
|
||||
bluetooth.autoswitch-to-headset-profile = false
|
||||
bluetooth.use-persistent-storage = false
|
||||
device.routes.default-sink-volume = 0.512
|
||||
}
|
||||
|
||||
monitor.bluez.properties = {
|
||||
bluez5.roles = [ a2dp_sink a2dp_source bap_sink bap_source hsp_hs hsp_ag hfp_hf hfp_ag ]
|
||||
bluez5.codecs = [ sbc sbc_xq aac ldac aptx aptx_hd aptx_ll aptx_ll_duplex faststream faststream_duplex opus_05 opus_05_51 opus_05_71 opus_05_dup opus_05_pro lc3 ]
|
||||
bluez5.enable-sbc-xq = true
|
||||
bluez5.enable-msbc = true
|
||||
bluez5.enable-msbc = false
|
||||
bluez5.enable-hw-volume = true
|
||||
bluez5.hfphsp-backend = "native"
|
||||
bluez5.hfphsp-backend-native-modem = "any"
|
||||
|
||||
Reference in new issue
Block a user