Commit 7fd89e49 authored by zhaochengyi's avatar zhaochengyi Committed by PulseAudio Marge Bot
Browse files

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: <!622>
parent f5b94eff
Pipeline #406645 passed with stages
in 2 minutes and 50 seconds
......@@ -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;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment