bluetooth: Add mechanism to track profile's status

Create pa_bluetooth_profile_status_t to represent all stages an external
Bluetooth profile can go through:

 0. Inactive: Initial state, no D-Bus object has been registered for
    this profile yet.
 1. Active: an object implementing the org.bluez.Profile1 interface has
    been registered on the system bus.
 2. Registering: RegisterProfile has been called.
 3. Registered: RegisterProfile succeeded.

This will be useful to handle RegisterProfile failures, as well as
dynamically register and un-register a profile based on the current
active seat.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/593>
This commit is contained in:
João Paulo Rechi Vita 2019-09-10 15:42:18 -07:00 committed by Igor Kovalenko
parent 28fd9bc319
commit 2f7c4969db
2 changed files with 19 additions and 0 deletions

View file

@ -140,6 +140,7 @@ struct pa_bluetooth_discovery {
pa_hashmap *adapters;
pa_hashmap *devices;
pa_hashmap *transports;
pa_bluetooth_profile_status_t profiles_status[PA_BLUETOOTH_PROFILE_COUNT];
int headset_backend;
pa_bluetooth_backend *ofono_backend, *native_backend;
@ -191,6 +192,14 @@ static const char *check_variant_property(DBusMessageIter *i) {
return key;
}
pa_bluetooth_profile_status_t profile_status_get(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile) {
return y->profiles_status[profile];
}
void profile_status_set(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile, pa_bluetooth_profile_status_t status) {
y->profiles_status[profile] = status;
}
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
pa_bluetooth_profile_t p, const uint8_t *config, size_t size) {
pa_bluetooth_transport *t;

View file

@ -84,6 +84,13 @@ typedef enum profile {
} pa_bluetooth_profile_t;
#define PA_BLUETOOTH_PROFILE_COUNT PA_BLUETOOTH_PROFILE_OFF
typedef enum pa_bluetooth_profile_status {
PA_BLUETOOTH_PROFILE_STATUS_INACTIVE,
PA_BLUETOOTH_PROFILE_STATUS_ACTIVE,
PA_BLUETOOTH_PROFILE_STATUS_REGISTERING,
PA_BLUETOOTH_PROFILE_STATUS_REGISTERED
} pa_bluetooth_profile_status_t;
typedef enum pa_bluetooth_transport_state {
PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED,
PA_BLUETOOTH_TRANSPORT_STATE_IDLE,
@ -192,6 +199,9 @@ static inline void pa_bluetooth_native_backend_free(pa_bluetooth_backend *b) {}
static inline void pa_bluetooth_native_backend_enable_shared_profiles(pa_bluetooth_backend *b, bool enable) {}
#endif
pa_bluetooth_profile_status_t profile_status_get(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile);
void profile_status_set(pa_bluetooth_discovery *y, pa_bluetooth_profile_t profile, pa_bluetooth_profile_status_t status);
pa_bluetooth_transport *pa_bluetooth_transport_new(pa_bluetooth_device *d, const char *owner, const char *path,
pa_bluetooth_profile_t p, const uint8_t *config, size_t size);