Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
sfos: bluez5: Add volume control.
Signed-off-by: Juho Hämäläinen <juho.hamalainen@jolla.com>
  • Loading branch information
jusa committed Feb 24, 2021
1 parent bb2d155 commit de10381
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/modules/bluetooth/bluez5-util.c
Expand Up @@ -38,6 +38,7 @@
#include "a2dp-codecs.h"

#include "bluez5-util.h"
#include "droid-volume.h"

#define WAIT_FOR_PROFILES_TIMEOUT_USEC (3 * PA_USEC_PER_SEC)

Expand Down Expand Up @@ -96,13 +97,29 @@ struct pa_bluetooth_discovery {
PA_LLIST_HEAD(pa_dbus_pending, pending);

bool droid_backend;
pa_droid_volume_control *droid_volume;
};

bool pa_bluetooth_droid_backend(pa_bluetooth_discovery *y) {
pa_assert(y);
return y->droid_backend;
}

void pa_bluetooth_droid_volume_control_acquire(pa_bluetooth_discovery *y, pa_bluetooth_transport *t) {
pa_assert(y);
pa_assert(t);

if (y->droid_backend && y->droid_volume)
pa_droid_volume_control_acquire(y->droid_volume, t);
}

void pa_bluetooth_droid_volume_control_release(pa_bluetooth_discovery *y) {
pa_assert(y);

if (y->droid_backend && y->droid_volume)
pa_droid_volume_control_release(y->droid_volume);
}

static pa_dbus_pending* send_and_add_to_pending(pa_bluetooth_discovery *y, DBusMessage *m,
DBusPendingCallNotifyFunction func, void *call_data) {
pa_dbus_pending *p;
Expand Down Expand Up @@ -1615,6 +1632,9 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backe
for (i = 0; i < PA_BLUETOOTH_HOOK_MAX; i++)
pa_hook_init(&y->hooks[i], y);

if (y->droid_backend)
y->droid_volume = pa_droid_volume_control_new(c, &y->hooks[PA_BLUETOOTH_HOOK_TRANSPORT_SPEAKER_GAIN_CHANGED]);

pa_shared_set(c, "bluetooth-discovery", y);

dbus_error_init(&err);
Expand Down Expand Up @@ -1697,6 +1717,8 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {

pa_dbus_free_pending_list(&y->pending);

if (y->droid_volume)
pa_droid_volume_control_free(y->droid_volume), y->droid_volume = NULL;
if (y->ofono_backend)
pa_bluetooth_ofono_backend_free(y->ofono_backend);
if (y->native_backend)
Expand Down
2 changes: 2 additions & 0 deletions src/modules/bluetooth/bluez5-util.h
Expand Up @@ -154,6 +154,8 @@ static inline void pa_bluetooth_native_backend_enable_hs_role(pa_bluetooth_backe
#endif

bool pa_bluetooth_droid_backend(pa_bluetooth_discovery *y);
void pa_bluetooth_droid_volume_control_acquire(pa_bluetooth_discovery *y, pa_bluetooth_transport *t);
void pa_bluetooth_droid_volume_control_release(pa_bluetooth_discovery *y);

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);
Expand Down

0 comments on commit de10381

Please sign in to comment.