Hi all,
after almost losing my faith in humanity in a time when the mobile world is dominated by two [...], there still seems to be a glimmer of hope. MANY thanks to all who were involved in the development of the PinePhone, and especially to those who were engaged in the creation of the various Linux distributions. For me a dream has come true.
Mobian is so great! What I'm not satisfied with is Bluetooth A2DP audio performance. In the default configuration, the sound stutters and after some time the Bluetooth stack reduces the data rate -- hoping to deliver stutter-free audio. I don't expect true HiFi on the go, but I'm no fan of stuttering and compressy-rattling mids either.
After doing some research, I've found various ways to fix this:
1. Increase the priority of PulseAudio
2. Increase the buffer size of the encoder
3. Install other codec modues and increase minimum allowed bitpool
In detail:
1. Increase the priority of PulseAudio
Basically follow the instructions from here: https://wiki.ubuntuusers.de/PulseAudio/#...t-erhoehen
In /etc/pulse/daemon.conf, add:
In /etc/security/limits.conf, add:
Reboot the PinePhone. The PulseAudio daemon should now run with a niceness of -11 (use the 'top' command to verify this).
2. Increase the buffer size of the encoder
Here's a script that increases the audio buffer. Connect the Bluetooth headphones, then run the script.
Steps 1 and 2 together should already dramatically reduce the stuttering.
3. Install other codec modues and increase minimum allowed bitpool
To get rid of the low data rates, follow the instructions here: https://github.com/EHfive/pulseaudio-modules-bt. This should also give you AptX support, but I have not tried this (don't have a compatible set). Some notes:
Install the required minimum packages:
Also install libpulse-dev, otherwise the backup of the original modules will fail. When running these commands, take them apart first. I mean, instead of directly executing
MODDIR=`pkg-config --variable=modlibexecdir libpulse`
fist try to run
pkg-config --variable=modlibexecdir libpulse
to see if that works.
Pull the sources and do the install mode "A. build for PulseAudio releases (e.g., v12.0, v12.2, etc.)". This worked for me.
Edit /etc/pulse/default.pa to configure everything.
In contrast to what's on the GitHub page, look for "discover", as there is already an entry for the module "module-bluetooth-disvover".
Play around with the parameters "sbc_min_bp" and "sbc_max_bp". To test if the new module is working, set both values to e.g. 2. Then run
pulseaudio -k; pulseaudio --start
Reconnect your headset and listen to some music. This setting should give a very low quality, but now you know it's working. Then try to find the highest possible values where the payback does not yet stutter. For me, around 36-38 seems to work (EDIT: 53, the maximum value, also works fine for me). If you're happy with the result, you can remove the "sbc_max_bp" option.
I haven't messed around with the other options. I would love to hear about experiences and settings.
All the best,
Sebastian
after almost losing my faith in humanity in a time when the mobile world is dominated by two [...], there still seems to be a glimmer of hope. MANY thanks to all who were involved in the development of the PinePhone, and especially to those who were engaged in the creation of the various Linux distributions. For me a dream has come true.
Mobian is so great! What I'm not satisfied with is Bluetooth A2DP audio performance. In the default configuration, the sound stutters and after some time the Bluetooth stack reduces the data rate -- hoping to deliver stutter-free audio. I don't expect true HiFi on the go, but I'm no fan of stuttering and compressy-rattling mids either.
After doing some research, I've found various ways to fix this:
1. Increase the priority of PulseAudio
2. Increase the buffer size of the encoder
3. Install other codec modues and increase minimum allowed bitpool
In detail:
1. Increase the priority of PulseAudio
Basically follow the instructions from here: https://wiki.ubuntuusers.de/PulseAudio/#...t-erhoehen
In /etc/pulse/daemon.conf, add:
Code:
high-priority = yes
rlimit-nice = 31
nice-level = -11
realtime-scheduling = ye
rlimit-rtprio = 9
realtime-priority = 9
In /etc/security/limits.conf, add:
Code:
mobian - nice -11
mobian - rtprio 99
Reboot the PinePhone. The PulseAudio daemon should now run with a niceness of -11 (use the 'top' command to verify this).
2. Increase the buffer size of the encoder
Here's a script that increases the audio buffer. Connect the Bluetooth headphones, then run the script.
Code:
# based on https://askubuntu.com/a/1207648 and https://askubuntu.com/a/171165
BLUEZCARD=`pactl list cards short | egrep -o bluez.*[[:space:]]`
pactl set-port-latency-offset $BLUEZCARD headset-output 100000
sudo service bluetooth restart
pactl list | grep -Pzo '.*bluez_card(.*\n)*'
Steps 1 and 2 together should already dramatically reduce the stuttering.
3. Install other codec modues and increase minimum allowed bitpool
To get rid of the low data rates, follow the instructions here: https://github.com/EHfive/pulseaudio-modules-bt. This should also give you AptX support, but I have not tried this (don't have a compatible set). Some notes:
Install the required minimum packages:
Code:
sudo apt install libpulse-dev git cmake libdbus-1-dev libsbc-dev libavcodec-dev libltdl-dev libbluetooth-dev
Also install libpulse-dev, otherwise the backup of the original modules will fail. When running these commands, take them apart first. I mean, instead of directly executing
MODDIR=`pkg-config --variable=modlibexecdir libpulse`
fist try to run
pkg-config --variable=modlibexecdir libpulse
to see if that works.
Pull the sources and do the install mode "A. build for PulseAudio releases (e.g., v12.0, v12.2, etc.)". This worked for me.
Edit /etc/pulse/default.pa to configure everything.
In contrast to what's on the GitHub page, look for "discover", as there is already an entry for the module "module-bluetooth-disvover".
Code:
.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover a2dp_config="sbc_min_bp=53 sbc_max_bp=53"
.endif
Play around with the parameters "sbc_min_bp" and "sbc_max_bp". To test if the new module is working, set both values to e.g. 2. Then run
pulseaudio -k; pulseaudio --start
Reconnect your headset and listen to some music. This setting should give a very low quality, but now you know it's working. Then try to find the highest possible values where the payback does not yet stutter. For me, around 36-38 seems to work (EDIT: 53, the maximum value, also works fine for me). If you're happy with the result, you can remove the "sbc_max_bp" option.
I haven't messed around with the other options. I would love to hear about experiences and settings.
All the best,
Sebastian