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
|
|
@ -713,10 +713,8 @@ fail:
|
|||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
||||
static int backend_ofono_add_filters(void *data)
|
||||
static int add_filters(struct impl *backend)
|
||||
{
|
||||
struct impl *backend = data;
|
||||
|
||||
DBusError err;
|
||||
|
||||
if (backend->filters_added)
|
||||
|
|
@ -765,9 +763,34 @@ static const struct spa_bt_backend_implementation backend_impl = {
|
|||
SPA_VERSION_BT_BACKEND_IMPLEMENTATION,
|
||||
.free = backend_ofono_free,
|
||||
.register_profiles = backend_ofono_register,
|
||||
.add_filters = backend_ofono_add_filters,
|
||||
};
|
||||
|
||||
static bool is_available(struct impl *backend)
|
||||
{
|
||||
DBusMessage *m, *r;
|
||||
DBusError err;
|
||||
bool success = false;
|
||||
|
||||
m = dbus_message_new_method_call(OFONO_SERVICE, "/",
|
||||
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)
|
||||
success = true;
|
||||
|
||||
if (r)
|
||||
dbus_message_unref(r);
|
||||
else
|
||||
dbus_error_free(&err);
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_dict *info,
|
||||
|
|
@ -787,6 +810,8 @@ struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
|||
|
||||
spa_bt_backend_set_implementation(&backend->this, &backend_impl, backend);
|
||||
|
||||
backend->this.name = "ofono";
|
||||
backend->this.exclusive = true;
|
||||
backend->monitor = monitor;
|
||||
backend->quirks = quirks;
|
||||
backend->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
||||
|
|
@ -805,5 +830,13 @@ struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (add_filters(backend) < 0) {
|
||||
dbus_connection_unregister_object_path(backend->conn, OFONO_AUDIO_CLIENT);
|
||||
free(backend);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
backend->this.available = is_available(backend);
|
||||
|
||||
return &backend->this;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue