【Fix Bug】RockChip平台Bluez-Alsa Source端播放卡住

概述

RockChip平台当时使用的Bluez-Alsa代码已经比较老了,但由于RK内部维护了一些补丁,因此并未直接使用同步最新的Bluez-Alsa代码,而是沿用老版本的代码。老版本代码存在一些BUG(新版本可能已经修复),本文就记录使用BT Souce功能时,播放会卡住,然后整个线程都被阻塞。此时调节蓝牙音量也是阻塞状态。现象log(阻塞在Connecting…):
在这里插入图片描述

解决补丁

原因:因多处对同一线程使用pthread_join,导致整个主进程阻塞,此时无法再接收新连接,也无法执行新的命令。

diff --git a/src/ctl.c b/src/ctl.c
old mode 100644
new mode 100755
index 88a7743..79d0183
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -161,8 +161,9 @@ static void _transport_release(struct ba_transport *t, int client) {
         * might try to acquire not yet released transport. To prevent this, we have
         * to make sure, that the transport is released (thread is terminated). */
        if (t->profile == BLUETOOTH_PROFILE_A2DP_SOURCE) {
-               pthread_cancel(t->thread);
-               pthread_join(t->thread, NULL);
+               pthread_t thread_tmp = t->thread;
+               pthread_cancel(thread_tmp);
+               pthread_join(thread_tmp, NULL);
        }
 
        switch (t->type) {
diff --git a/src/transport.c b/src/transport.c
old mode 100644
new mode 100755
index bca44b9..2a2b46e
--- a/src/transport.c
+++ b/src/transport.c
@@ -705,7 +705,7 @@ int transport_set_state(struct ba_transport *t, enum ba_transport_state state) {
 
        switch (state) {
        case TRANSPORT_IDLE:
-               if (created) {
+               if (created && (t->profile != BLUETOOTH_PROFILE_A2DP_SOURCE)) {
                        pthread_cancel(t->thread);
                        ret = pthread_join(t->thread, NULL);
                }
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值