mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
bluez5: Share DBus connection between all backends
This commit is contained in:
parent
34fc7ff529
commit
4fb56ee69b
4 changed files with 15 additions and 25 deletions
|
|
@ -44,7 +44,6 @@ struct spa_bt_backend {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
struct spa_dbus *dbus;
|
||||
struct spa_dbus_connection *dbus_connection;
|
||||
DBusConnection *conn;
|
||||
};
|
||||
|
||||
|
|
@ -643,6 +642,7 @@ void backend_hsp_native_free(struct spa_bt_backend *backend)
|
|||
}
|
||||
|
||||
struct spa_bt_backend *backend_hsp_native_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support)
|
||||
{
|
||||
|
|
@ -656,14 +656,7 @@ struct spa_bt_backend *backend_hsp_native_new(struct spa_bt_monitor *monitor,
|
|||
backend->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
||||
backend->dbus = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DBus);
|
||||
backend->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop);
|
||||
|
||||
backend->dbus_connection = spa_dbus_get_connection(backend->dbus, SPA_DBUS_TYPE_SYSTEM);
|
||||
if (backend->dbus_connection == NULL) {
|
||||
spa_log_error(backend->log, "no dbus connection");
|
||||
free(backend);
|
||||
return NULL;
|
||||
}
|
||||
backend->conn = spa_dbus_connection_get(backend->dbus_connection);
|
||||
backend->conn = dbus_connection;
|
||||
|
||||
return backend;
|
||||
}
|
||||
|
|
@ -45,7 +45,6 @@ struct spa_bt_backend {
|
|||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
struct spa_dbus *dbus;
|
||||
struct spa_dbus_connection *dbus_connection;
|
||||
DBusConnection *conn;
|
||||
|
||||
unsigned int filters_added:1;
|
||||
|
|
@ -337,7 +336,7 @@ static DBusHandlerResult ofono_new_audio_connection(DBusConnection *conn, DBusMe
|
|||
|
||||
fail:
|
||||
if (r) {
|
||||
dbus_connection_send(spa_dbus_connection_get(backend->dbus_connection), r, NULL);
|
||||
dbus_connection_send(backend->conn, r, NULL);
|
||||
dbus_message_unref(r);
|
||||
}
|
||||
|
||||
|
|
@ -602,6 +601,7 @@ void backend_ofono_free(struct spa_bt_backend *backend)
|
|||
}
|
||||
|
||||
struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support)
|
||||
{
|
||||
|
|
@ -618,14 +618,7 @@ struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
|||
backend->log = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Log);
|
||||
backend->dbus = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DBus);
|
||||
backend->main_loop = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_Loop);
|
||||
|
||||
backend->dbus_connection = spa_dbus_get_connection(backend->dbus, SPA_DBUS_TYPE_SYSTEM);
|
||||
if (backend->dbus_connection == NULL) {
|
||||
spa_log_error(backend->log, "no dbus connection");
|
||||
free(backend);
|
||||
return NULL;
|
||||
}
|
||||
backend->conn = spa_dbus_connection_get(backend->dbus_connection);
|
||||
backend->conn = dbus_connection;
|
||||
|
||||
if (!dbus_connection_register_object_path(backend->conn,
|
||||
OFONO_AUDIO_CLIENT,
|
||||
|
|
|
|||
|
|
@ -1742,8 +1742,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
spa_list_init(&this->device_list);
|
||||
spa_list_init(&this->transport_list);
|
||||
|
||||
this->backend_hsp_native = backend_hsp_native_new(this, support, n_support);
|
||||
this->backend_ofono = backend_ofono_new(this, support, n_support);
|
||||
this->backend_hsp_native = backend_hsp_native_new(this, this->conn, support, n_support);
|
||||
this->backend_ofono = backend_ofono_new(this, this->conn, support, n_support);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -299,14 +299,16 @@ static inline enum spa_bt_transport_state spa_bt_transport_state_from_string(con
|
|||
|
||||
#ifdef HAVE_BLUEZ_5_BACKEND_NATIVE
|
||||
struct spa_bt_backend *backend_hsp_native_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support);
|
||||
uint32_t n_support);
|
||||
void backend_hsp_native_free(struct spa_bt_backend *backend);
|
||||
void backend_hsp_native_register_profiles(struct spa_bt_backend *backend);
|
||||
#else
|
||||
static inline struct spa_bt_backend *backend_hsp_native_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support) {
|
||||
uint32_t n_support) {
|
||||
return NULL;
|
||||
}
|
||||
static inline void backend_hsp_native_free(struct spa_bt_backend *backend) {}
|
||||
|
|
@ -315,14 +317,16 @@ static inline void backend_hsp_native_register_profiles(struct spa_bt_backend *b
|
|||
|
||||
#ifdef HAVE_BLUEZ_5_BACKEND_OFONO
|
||||
struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support);
|
||||
uint32_t n_support);
|
||||
void backend_ofono_free(struct spa_bt_backend *backend);
|
||||
void backend_ofono_add_filters(struct spa_bt_backend *backend);
|
||||
#else
|
||||
static inline struct spa_bt_backend *backend_ofono_new(struct spa_bt_monitor *monitor,
|
||||
void *dbus_connection,
|
||||
const struct spa_support *support,
|
||||
uint32_t n_support) {
|
||||
uint32_t n_support) {
|
||||
return NULL;
|
||||
}
|
||||
static inline void backend_ofono_free(struct spa_bt_backend *backend) {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue