bluez5: implement HFP codec switching

Implement switching HFP codecs in bluez5-devices, currently only for
backend-native.

Codecs are exposed via profiles similarly as for A2DP.

Some hardware appears to not properly reply to the +BCS message. Catch
these cases with a timeout, in which case we fall back to previously
existing transports.
This commit is contained in:
Pauli Virtanen 2021-03-18 23:15:03 +02:00 committed by Wim Taymans
parent e18df4e344
commit 79e098bdf2
4 changed files with 348 additions and 71 deletions

View file

@ -2206,6 +2206,26 @@ int spa_bt_device_ensure_a2dp_codec(struct spa_bt_device *device, const struct a
return 0;
}
int spa_bt_device_ensure_hfp_codec(struct spa_bt_device *device, unsigned int codec)
{
struct spa_bt_monitor *monitor = device->monitor;
if (monitor->backend_hsphfpd_registered)
return spa_bt_backend_ensure_codec(monitor->backend_hsphfpd, device, codec);
if (monitor->backend_ofono_registered)
return spa_bt_backend_ensure_codec(monitor->backend_ofono, device, codec);
return spa_bt_backend_ensure_codec(monitor->backend_native, device, codec);
}
int spa_bt_device_supports_hfp_codec(struct spa_bt_device *device, unsigned int codec)
{
struct spa_bt_monitor *monitor = device->monitor;
if (monitor->backend_hsphfpd_registered)
return spa_bt_backend_supports_codec(monitor->backend_hsphfpd, device, codec);
if (monitor->backend_ofono_registered)
return spa_bt_backend_supports_codec(monitor->backend_ofono, device, codec);
return spa_bt_backend_supports_codec(monitor->backend_native, device, codec);
}
static DBusHandlerResult endpoint_set_configuration(DBusConnection *conn,
const char *path, DBusMessage *m, void *userdata)
{