[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] bluetooth: Try to reconnect SCO
PulseAudio Marge Bot (@pulseaudio-merge-bot)
gitlab at gitlab.freedesktop.org
Wed Sep 22 15:16:42 UTC 2021
PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio
Commits:
7fd89e49 by Chengyi Zhao at 2021-09-22T15:13:26+00:00
bluetooth: Try to reconnect SCO
When the SCO connection is in use, if you disconnect first and then connect,
the SCO connection will occasionally fail, and the Bluetooth error code is 42
(0x2A in hexadecimal). This is usually because an error occurred when the SCO
connection was initiated, we need to try to reconnect to optimize the handling
of this problem. The log returned by the kernel is as follows:
Bluetooth: sco_connect_cfm: hcon 0000000003328902 bdaddr 40:ef:4c:0c:11:f0 status 42
Bluetooth: sco_sock_connect status is -38
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/622>
- - - - -
1 changed file:
- src/modules/bluetooth/backend-native.c
Changes:
=====================================
src/modules/bluetooth/backend-native.c
=====================================
@@ -108,6 +108,9 @@ static uint32_t hfp_features =
* The choice seems to be a bit arbitrary -- it looks like at least channels 2, 4 and 5 also work*/
#define HSP_HS_DEFAULT_CHANNEL 3
+/* Total number of trying to reconnect */
+#define SCO_RECONNECTION_COUNT 3
+
#define PROFILE_INTROSPECT_XML \
DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE \
"<node>" \
@@ -320,11 +323,22 @@ fail:
static int sco_acquire_cb(pa_bluetooth_transport *t, bool optional, size_t *imtu, size_t *omtu) {
int sock;
socklen_t len;
+ int i;
if (optional)
sock = sco_do_accept(t);
- else
- sock = sco_do_connect(t);
+ else {
+ for (i = 0; i < SCO_RECONNECTION_COUNT; i++) {
+ sock = sco_do_connect(t);
+
+ if (sock < 0) {
+ pa_log_debug("err is %s and reconnection count is %d", pa_cstrerror(errno), i);
+ pa_msleep(300);
+ continue;
+ } else
+ break;
+ }
+ }
if (sock < 0)
goto fail;
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/7fd89e491f5d818cb3e9ba609d7e7577990b1887
--
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/commit/7fd89e491f5d818cb3e9ba609d7e7577990b1887
You're receiving this email because of your account on gitlab.freedesktop.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210922/0ed7eceb/attachment-0001.htm>
More information about the pulseaudio-commits
mailing list