mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
bluez5: backend-native: fallback switch msbc->cvsd on EOPNOTSUPP
If MSBC connect() fails with EOPNOTSUPP, trigger codec renegotiation. When PW is AG, this also removes the msbc profile.
This commit is contained in:
parent
1da23145df
commit
3ffc0452a7
1 changed files with 20 additions and 4 deletions
|
|
@ -1130,6 +1130,7 @@ static int sco_do_connect(struct spa_bt_transport *t)
|
|||
{
|
||||
struct impl *backend = SPA_CONTAINER_OF(t->backend, struct impl, this);
|
||||
struct spa_bt_device *d = t->device;
|
||||
struct transport_data *td = t->user_data;
|
||||
struct sockaddr_sco addr;
|
||||
socklen_t len;
|
||||
int err;
|
||||
|
|
@ -1164,6 +1165,21 @@ again:
|
|||
goto again;
|
||||
} else if (err < 0 && !(errno == EAGAIN || errno == EINPROGRESS)) {
|
||||
spa_log_error(backend->log, "connect(): %s", strerror(errno));
|
||||
#ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE
|
||||
if (errno == EOPNOTSUPP && t->codec == HFP_AUDIO_CODEC_MSBC &&
|
||||
td->rfcomm->msbc_supported_by_hfp) {
|
||||
/* Adapter doesn't support msbc. Renegotiate. */
|
||||
d->adapter->msbc_probed = true;
|
||||
d->adapter->has_msbc = false;
|
||||
td->rfcomm->msbc_supported_by_hfp = false;
|
||||
if (t->profile == SPA_BT_PROFILE_HFP_HF) {
|
||||
td->rfcomm->hfp_ag_switching_codec = true;
|
||||
rfcomm_send_reply(td->rfcomm, "+BCS: 1");
|
||||
} else if (t->profile == SPA_BT_PROFILE_HFP_AG) {
|
||||
rfcomm_send_cmd(td->rfcomm, "AT+BAC=1");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
goto fail_close;
|
||||
}
|
||||
|
||||
|
|
@ -1184,10 +1200,6 @@ static int sco_acquire_cb(void *data, bool optional)
|
|||
|
||||
spa_log_debug(backend->log, "transport %p: enter sco_acquire_cb", t);
|
||||
|
||||
#ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE
|
||||
rfcomm_hfp_ag_set_cind(td->rfcomm, true);
|
||||
#endif
|
||||
|
||||
if (optional || t->fd > 0)
|
||||
sock = t->fd;
|
||||
else
|
||||
|
|
@ -1196,6 +1208,10 @@ static int sco_acquire_cb(void *data, bool optional)
|
|||
if (sock < 0)
|
||||
goto fail;
|
||||
|
||||
#ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE
|
||||
rfcomm_hfp_ag_set_cind(td->rfcomm, true);
|
||||
#endif
|
||||
|
||||
t->fd = sock;
|
||||
|
||||
/* Fallback value */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue