mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
bluetooth: use native and ofono backends in parallel with headset=auto
This patch changes the behavior of the headset=auto switch for module-bluez5-discover. With headset=auto now both backends will be active at the same time for the AG role and the switching between the backends is only done for the HS role. headset=ofono and headset=native remain unchanged. This allows to use old HSP only headsets while running ofono and to have headset support via pulseaudio if ofono is started with the --noplugin=hfp_ag_bluez5 option.
This commit is contained in:
parent
d065e4d114
commit
adc2e8cd0a
3 changed files with 27 additions and 13 deletions
|
|
@ -40,6 +40,7 @@ struct pa_bluetooth_backend {
|
||||||
pa_core *core;
|
pa_core *core;
|
||||||
pa_dbus_connection *connection;
|
pa_dbus_connection *connection;
|
||||||
pa_bluetooth_discovery *discovery;
|
pa_bluetooth_discovery *discovery;
|
||||||
|
bool enable_hs_role;
|
||||||
|
|
||||||
PA_LLIST_HEAD(pa_dbus_pending, pending);
|
PA_LLIST_HEAD(pa_dbus_pending, pending);
|
||||||
};
|
};
|
||||||
|
|
@ -657,7 +658,20 @@ static void profile_done(pa_bluetooth_backend *b, pa_bluetooth_profile_t profile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
|
void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backend *native_backend, bool enable_hs_role) {
|
||||||
|
|
||||||
|
if (enable_hs_role == native_backend->enable_hs_role)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (enable_hs_role)
|
||||||
|
profile_init(native_backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
|
||||||
|
else
|
||||||
|
profile_done(native_backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
|
||||||
|
|
||||||
|
native_backend->enable_hs_role = enable_hs_role;
|
||||||
|
}
|
||||||
|
|
||||||
|
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role) {
|
||||||
pa_bluetooth_backend *backend;
|
pa_bluetooth_backend *backend;
|
||||||
DBusError err;
|
DBusError err;
|
||||||
|
|
||||||
|
|
@ -675,7 +689,9 @@ pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_d
|
||||||
}
|
}
|
||||||
|
|
||||||
backend->discovery = y;
|
backend->discovery = y;
|
||||||
|
backend->enable_hs_role = enable_hs_role;
|
||||||
|
|
||||||
|
if (enable_hs_role)
|
||||||
profile_init(backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
|
profile_init(backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
|
||||||
profile_init(backend, PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT);
|
profile_init(backend, PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT);
|
||||||
|
|
||||||
|
|
@ -687,6 +703,7 @@ void pa_bluetooth_native_backend_free(pa_bluetooth_backend *backend) {
|
||||||
|
|
||||||
pa_dbus_free_pending_list(&backend->pending);
|
pa_dbus_free_pending_list(&backend->pending);
|
||||||
|
|
||||||
|
if (backend->enable_hs_role)
|
||||||
profile_done(backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
|
profile_done(backend, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY);
|
||||||
profile_done(backend, PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT);
|
profile_done(backend, PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -982,12 +982,7 @@ void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is
|
||||||
if (y->headset_backend != HEADSET_BACKEND_AUTO)
|
if (y->headset_backend != HEADSET_BACKEND_AUTO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (is_running && y->native_backend) {
|
pa_bluetooth_native_backend_enable_hs_role(y->native_backend, !is_running);
|
||||||
pa_bluetooth_native_backend_free(y->native_backend);
|
|
||||||
y->native_backend = NULL;
|
|
||||||
}
|
|
||||||
else if (!is_running && !y->native_backend)
|
|
||||||
y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata) {
|
static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata) {
|
||||||
|
|
@ -1028,10 +1023,10 @@ static void get_managed_objects_reply(DBusPendingCall *pending, void *userdata)
|
||||||
|
|
||||||
y->objects_listed = true;
|
y->objects_listed = true;
|
||||||
|
|
||||||
|
if (!y->native_backend && y->headset_backend != HEADSET_BACKEND_OFONO)
|
||||||
|
y->native_backend = pa_bluetooth_native_backend_new(y->core, y, (y->headset_backend == HEADSET_BACKEND_NATIVE));
|
||||||
if (!y->ofono_backend && y->headset_backend != HEADSET_BACKEND_NATIVE)
|
if (!y->ofono_backend && y->headset_backend != HEADSET_BACKEND_NATIVE)
|
||||||
y->ofono_backend = pa_bluetooth_ofono_backend_new(y->core, y);
|
y->ofono_backend = pa_bluetooth_ofono_backend_new(y->core, y);
|
||||||
if (!y->ofono_backend && !y->native_backend && y->headset_backend != HEADSET_BACKEND_OFONO)
|
|
||||||
y->native_backend = pa_bluetooth_native_backend_new(y->core, y);
|
|
||||||
|
|
||||||
finish:
|
finish:
|
||||||
dbus_message_unref(r);
|
dbus_message_unref(r);
|
||||||
|
|
|
||||||
|
|
@ -129,13 +129,15 @@ static inline void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *b) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
|
#ifdef HAVE_BLUEZ_5_NATIVE_HEADSET
|
||||||
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y);
|
pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role);
|
||||||
void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b);
|
void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b);
|
||||||
|
void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backend *b, bool enable_hs_role);
|
||||||
#else
|
#else
|
||||||
static inline pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y) {
|
static inline pa_bluetooth_backend *pa_bluetooth_native_backend_new(pa_core *c, pa_bluetooth_discovery *y, bool enable_hs_role) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {}
|
static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {}
|
||||||
|
static inline void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backend *b, bool enable_hs_role) {}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
|
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue