diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index 8162417..c5d8ab1 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
target_player = avrcp_get_target_player_by_device(device);
if (!target_player)
- return -1;
+ goto done;
adapter = find_adapter(device);
if (!adapter)
- return -1;
+ goto done;
for (l = adapter->players; l; l = l->next) {
struct media_player *mp = l->data;
return mp->volume;
}
- return -1;
+done:
+ /* If media_player doesn't exists use device_volume */
+ return btd_device_get_volume(device);
}
static gboolean set_configuration(struct media_endpoint *endpoint,
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index d158fc9..5848e40 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
if (dev == NULL)
return -1;
+ /* Attempt to locate the transport to get its volume */
for (l = transports; l; l = l->next) {
struct media_transport *transport = l->data;
if (transport->device != dev)
return media_transport_get_volume(transport);
}
- return 0;
+ /* If transport volume doesn't exists use device_volume */
+ return btd_device_get_volume(dev);
}
void media_transport_update_device_volume(struct btd_device *dev,
if (dev == NULL || volume < 0)
return;
+ /* Attempt to locate the transport to set its volume */
for (l = transports; l; l = l->next) {
struct media_transport *transport = l->data;
if (transport->device != dev)
continue;
/* Volume is A2DP only */
- if (media_endpoint_get_sep(transport->endpoint))
+ if (media_endpoint_get_sep(transport->endpoint)) {
media_transport_update_volume(transport, volume);
+ return;
+ }
}
+
+ /* If transport volume doesn't exists add to device_volume */
+ btd_device_set_volume(dev, volume);
}
diff --git a/src/device.c b/src/device.c
index 38f4993..112bcc1 100644
--- a/src/device.c
+++ b/src/device.c
guint store_id;
time_t name_resolve_failed_time;
+
+ int8_t volume;
};
static const uint16_t uuid_list[] = {
return NULL;
device->tx_power = 127;
+ device->volume = -1;
device->db = gatt_db_new();
if (!device->db) {
{
btd_service_remove_state_cb(service_state_cb_id);
}
+
+void btd_device_set_volume(struct btd_device *device, int8_t volume)
+{
+ device->volume = volume;
+}
+
+int8_t btd_device_get_volume(struct btd_device *device)
+{
+ return device->volume;
+}
diff --git a/src/device.h b/src/device.h
index 071576d..9cdc0e6 100644
--- a/src/device.h
+++ b/src/device.h
void btd_device_update_allowed_services(struct btd_device *dev);
void btd_device_init(void);
void btd_device_cleanup(void);
+
+void btd_device_set_volume(struct btd_device *dev, int8_t volume);
+int8_t btd_device_get_volume(struct btd_device *dev);