mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
bluez5: backend-native: fix codec handling with simultaneous HF & AG
It may occur that we have RFCOMM connected as both HF and AG. The codec switching and support checks should in this case always use the remote HF RFCOMM. Fix by finding the RFCOMM with the correct profile, remote as HF.
This commit is contained in:
parent
099e2cf27a
commit
5f7afe588c
1 changed files with 9 additions and 6 deletions
|
|
@ -1915,11 +1915,12 @@ static const struct spa_bt_transport_implementation sco_transport_impl = {
|
|||
.destroy = sco_destroy_cb,
|
||||
};
|
||||
|
||||
static struct rfcomm *device_find_rfcomm(struct impl *backend, struct spa_bt_device *device)
|
||||
static struct rfcomm *device_find_rfcomm(struct impl *backend, struct spa_bt_device *device,
|
||||
enum spa_bt_profile profile)
|
||||
{
|
||||
struct rfcomm *rfcomm;
|
||||
spa_list_for_each(rfcomm, &backend->rfcomm_list, link) {
|
||||
if (rfcomm->device == device)
|
||||
if (rfcomm->device == device && (rfcomm->profile & profile))
|
||||
return rfcomm;
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -1931,8 +1932,8 @@ static int backend_native_supports_codec(void *data, struct spa_bt_device *devic
|
|||
struct impl *backend = data;
|
||||
struct rfcomm *rfcomm;
|
||||
|
||||
rfcomm = device_find_rfcomm(backend, device);
|
||||
if (rfcomm == NULL || rfcomm->profile != SPA_BT_PROFILE_HFP_HF)
|
||||
rfcomm = device_find_rfcomm(backend, device, SPA_BT_PROFILE_HFP_HF);
|
||||
if (rfcomm == NULL)
|
||||
return -ENOTSUP;
|
||||
|
||||
if (codec == HFP_AUDIO_CODEC_CVSD)
|
||||
|
|
@ -2097,10 +2098,12 @@ static int backend_native_ensure_codec(void *data, struct spa_bt_device *device,
|
|||
int res;
|
||||
|
||||
res = backend_native_supports_codec(data, device, codec);
|
||||
if (res <= 0)
|
||||
if (res < 0)
|
||||
return res;
|
||||
else if (!res)
|
||||
return -EINVAL;
|
||||
|
||||
rfcomm = device_find_rfcomm(backend, device);
|
||||
rfcomm = device_find_rfcomm(backend, device, SPA_BT_PROFILE_HFP_HF);
|
||||
if (rfcomm == NULL)
|
||||
return -ENOTSUP;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue