mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
bluez5: cleanup hfp/hsp backend handling + config file option
It seems not uncommon that people have not properly configured ofono running, which results to loss of HFP/HSP functionality. It's less surprising if the backend selection is fixed in the configuration file, and (by default) does not depend on running services. Add a configuration file option for selecting HFP/HSP backend, and set the default value to the native backend. Emit warnings if conflicting backend services are detected to be running. Also cleanup hfp/hsp backend handling a bit, now that it's mostly abstracted behind an interface.
This commit is contained in:
parent
cae1554449
commit
90b4efd98d
6 changed files with 236 additions and 109 deletions
|
|
@ -2126,6 +2126,38 @@ static const struct spa_bt_backend_implementation backend_impl = {
|
|||
.supports_codec = backend_native_supports_codec,
|
||||
};
|
||||
|
||||
static bool is_available(struct impl *backend)
|
||||
{
|
||||
DBusMessage *m, *r;
|
||||
DBusError err;
|
||||
bool success = false;
|
||||
|
||||
m = dbus_message_new_method_call(BLUEZ_SERVICE, "/org/bluez",
|
||||
DBUS_INTERFACE_INTROSPECTABLE, "Introspect");
|
||||
if (m == NULL)
|
||||
return false;
|
||||
|
||||
dbus_error_init(&err);
|
||||
r = dbus_connection_send_with_reply_and_block(backend->conn, m, -1, &err);
|
||||
dbus_message_unref(m);
|
||||
|
||||
if (r && dbus_message_get_type(r) == DBUS_MESSAGE_TYPE_METHOD_RETURN) {
|
||||
const char *str;
|
||||
if (dbus_message_get_args(r, &err, DBUS_TYPE_STRING, &str, DBUS_TYPE_INVALID)) {
|
||||
success = strstr(str, BLUEZ_PROFILE_MANAGER_INTERFACE) != NULL;
|
||||
} else {
|
||||
dbus_error_free(&err);
|
||||
}
|
||||
}
|
||||
|
||||
if (r)
|
||||
dbus_message_unref(r);
|
||||
else
|
||||
dbus_error_free(&err);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
struct spa_bt_backend *backend_native_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_dict *info,
|
||||
|
|
@ -2145,6 +2177,7 @@ struct spa_bt_backend *backend_native_new(struct spa_bt_monitor *monitor,
|
|||
|
||||
spa_bt_backend_set_implementation(&backend->this, &backend_impl, backend);
|
||||
|
||||
backend->this.name = "native";
|
||||
backend->monitor = monitor;
|
||||
backend->quirks = quirks;
|
||||
backend->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
||||
|
|
@ -2187,6 +2220,8 @@ struct spa_bt_backend *backend_native_new(struct spa_bt_monitor *monitor,
|
|||
}
|
||||
#endif
|
||||
|
||||
backend->this.available = is_available(backend);
|
||||
|
||||
return &backend->this;
|
||||
|
||||
#ifdef HAVE_BLUEZ_5_BACKEND_HFP_NATIVE
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue