15.11蓝牙音频滞后卡顿问题解决方法
Tofloor
poster avatar
a285654974
deepin
2019-08-23 06:42
Author
本帖最后由 a285654974 于 2019-8-23 09:58 编辑

Deepin15.11使用下来存在严重的蓝牙问题,主要体现在音频滞后严重,频繁出现卡顿。
本人设备联想Z50笔记本i5-4210U,GeForce 840M,RTL8723BE蓝牙一体无线网卡。
解决方案为使用第三方蓝牙音频codec模块:pulseaudio-modules-bt。
该方法在本人设备上有效,不保证其他平台效果。

具体方法如下:1.升级pulseaudio到12.2
deepin自带的pulseaudio是10.0版本,pulseaudio-modules-bt需要12版本以上
官网:https://www.freedesktop.org/wiki/Software/PulseAudio/
sudo vim /etc/apt/sources.list
将#deb-src的注释去掉
安装编译依赖:
sudo apt install build-essential
sudo apt-get build-dep pulseaudio
下载源码
git clone git://anongit.freedesktop.org/pulseaudio/pulseaudio
检出到12.2
cd pulseaudio && git checkout v12.2
编译
./bootstrap.sh
make
sudo make install
rm -rf ~/.config/pulse/
完成后重启

2.安装cmake
deepin仓库里的cmake是3.9.5版本,编译pulseaudio-modules-bt需要cmake3.11以上版本
官网:https://cmake.org/download/
下载最新版本(截止20190822是3.15.2)
wget https://github.com/Kitware/CMake ... Linux-x86_64.tar.gz
安装到系统
tar -vxpf cmake-3.15.2-Linux-x86_64.tar.gz
sudo cp -r cmake-3.15.2-Linux-x86_64/* /usr/

3.安装ffmpeg(可选,aptX、aptX-HD编码支持)
pulseaudio-modules-bt编译要求ffmpeg大于4.0,deepin自带版本为3.2.12
官网:https://ffmpeg.org/download.html
下载最新版(截止20190822是4.2)
wget https://ffmpeg.org/releases/ffmpeg-4.2.tar.bz2
安装编译依赖:
sudo apt install nasm yasm
编译:
tar -vxf ffmpeg-4.2.tar.bz2
cd ffmpeg-4.2
./configure
make
sudo make install


4.安装fdk-aac(可选,AAC编码支持)
pulseaudio-modules-bt编译要求fdk-aac大于0.1.5,deepin自带版本为0.1.4
官网:https://github.com/mstorsjo/fdk-aac
git clone https://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
git checkout v2.0.0
./autogen.sh
./configure
make
sudo make install


5.安装ldacBT(可选,LDAC编码支持)
pulseaudio-modules-bt编译要求ldacBT或者libldac,deepin仓库中不存在
官网:https://github.com/EHfive/ldacBT
git clone https://github.com/EHfive/ldacBT.git
cd ldacBT
git checkout v2.0.23
git submodule update --init
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/usr -DINSTALL_LIBDIR=/usr/lib -DLDAC_SOFT_FLOAT=OFF ..
sudo make DESTDIR=$DEST_DIR install


6.安装pulseaudio-modules-bt
官网:https://github.com/EHfive/pulseaudio-modules-bt
安装编译依赖
sudo apt install libbluetooth-dev libsbc-dev libdbus-1-dev bluez pkg-config libtool
备份原始的pulseaudio bt modules:
MODDIR=`pkg-config --variable=modlibexecdir libpulse`
sudo find $MODDIR -regex ".*\(bluez5\|bluetooth\).*\.so" -exec cp {} {}.bak \;
下载源码:
git clone https://github.com/EHfive/pulseaudio-modules-bt.git
cd pulseaudio-modules-bt
git submodule update --init
编译安装:
git -C pa/ checkout v`pkg-config libpulse --modversion|sed 's/[^0-9.]*\([0-9.]*\).*/\1/'`
mkdir build && cd build
cmake ..
make
sudo make install
加载模块
pulseaudio -k
pulseaudio --start

7.手动选择codec(可选,默认自动选择LDAC > APTX HD > APTX > SBC)
修改/usr/lib/systemd/system/bluetooth.service

[Unit]
Description=Bluetooth service
Documentation=man:bluetoothd(8)
ConditionPathIsDirectory=/sys/class/bluetooth

[Service]
Type=dbus
BusName=org.bluez
ExecStart=/usr/lib/bluetoothd -E
NotifyAccess=main
#WatchdogSec=10
#Restart=on-failure
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
LimitNPROC=1
ProtectHome=true
ProtectSystem=full

[Install]
WantedBy=bluetooth.target

在启动项目后面增加 -E,最终变成:
ExecStart=/usr/lib/bluetooth/bluetoothd -E

重启蓝牙服务
systemctl daemon-reload
systemctl restart bluetooth

使用命令 pactl set-card-profile 切换
或者安装pavucontrol,图形化操作


参考
https://github.com/EHfive/pulseaudio-modules-bt
https://github.com/EHfive/pulseaudio-modules-bt/wiki
https://plumz.me/archives/10518/
https://sparkydogx.github.io/2018/10/29/fix-sound-in-ubuntu/



Reply Favorite View the author
All Replies
avatar
a285654974
deepin
2019-08-23 06:53
#1
https://bbs.deepin.org/user/1647 https://bbs.deepin.org/user/4892 https://bbs.deepin.org/user/122443 论坛的审核机制是否有问题,我编辑的帖子内容就是上述附件中的文本,提交后提示“抱歉您填写的信息包含不良信息而无法提交”。整个内容没有任何问题啊。
Reply View the author
avatar
181******81
deepin
2019-08-23 17:23
#2
很赞。这个真的有用。我还以为是蓝牙驱动出问题了。
Reply View the author
avatar
昨夜的星辰
deepin
2019-08-23 17:25
#3
不知道是不是你帖子里的各种地址搞的
Reply View the author
avatar
a285654974
deepin
2019-08-23 17:57
#4
https://bbs.deepin.org/post/182114
@youyou2011 @diyiliaoya @lkzxing 论坛的审核机制是否有问题,我编辑的帖子内容就是上述附件中的文本,提 ...

谁能告诉我,”解、码、器“三个字哪儿里不良了?????
Reply View the author
avatar
a285654974
deepin
2019-08-23 18:04
#5
https://bbs.deepin.org/post/182114
很赞。这个真的有用。我还以为是蓝牙驱动出问题了。

蓝牙这个问题我也是折腾了很久,后来网上搜到这个第三方codec这个项目,据说是逆向工程的原因,pulseaudio上游还在争论是否应该合并代码。不过ldac这个协议好像sony已经开源了。我的蓝牙耳机没那么好,只支持标准的sbc协议,但是用pulseaudio-modules-bt也解决延迟卡顿的问题。
我觉得deepin的蓝牙驱动应该确实是有问题的,我会出现连不上蓝牙的情况,要多试几次才行,蓝牙服务也能在日志里看到报错,不知道你有没有遇到这样的问题。
Reply View the author
avatar
a285654974
deepin
2019-08-23 18:05
#6
https://bbs.deepin.org/post/182114
不知道是不是你帖子里的各种地址搞的

”解码、器“三个子搞的鬼,不过我奇怪了,这三个字咋就成敏感字了?
Reply View the author
avatar
geno
deepin
2019-08-23 18:07
#7
这个都是版本太老惹的祸,自从debian10发布后,9就过时了。
Reply View the author
avatar
a285654974
deepin
2019-08-23 20:50
#8
本帖最后由 a285654974 于 2019-8-23 12:52 编辑
https://bbs.deepin.org/post/182114
这个都是版本太老惹的祸,自从debian10发布后,9就过时了。

额,貌似我升级pulseaudio到12.2后依然存在问题,不知道是不是我的个案。使用了第三方的codec才算解决问题。
另外我觉得这种影响用户体验,但实际上已有解决方案的问题,deepin是不是官方应该做下backport
Reply View the author
avatar
jianguo922
deepin
2019-08-24 02:43
#9
我的蓝牙AR3012找了整个网络,没有找到解决办法
https://bbs.deepin.org/post/181703
Reply View the author
avatar
foxfly
deepin
2020-03-13 01:22
#10
特地来赞一下!原带的蓝牙音乐是灾难
Reply View the author
avatar
wwwkljoel
deepin
2022-04-04 19:36
#11

新版本问题得到了改善(20.5), 偶尔卡顿,包括蓝牙鼠标、音箱一起,关闭蓝牙,重新链接可以解决。 但这是权宜之策,不是根本,好在出现次数少

Reply View the author