From cc0af04343e08cf5dace8d09f80735aa6fc1ab3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Date: Fri, 11 Jan 2013 17:25:29 -0300 Subject: [PATCH] transport: Get volume passing only audio_device --- profiles/audio/transport.c | 20 ++++++++++++++++++++ profiles/audio/transport.h | 2 ++ 2 files changed, 22 insertions(+) diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c index 0d993a40f..7e44f207e 100644 --- a/profiles/audio/transport.c +++ b/profiles/audio/transport.c @@ -878,3 +878,23 @@ void media_transport_update_volume(struct media_transport *transport, transport->path, MEDIA_TRANSPORT_INTERFACE, "Volume"); } + +uint8_t media_transport_get_device_volume(struct audio_device *dev) +{ + GSList *l; + + if (dev == NULL) + return 128; + + 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)) + return media_transport_get_volume(transport); + } + + return 128; +} diff --git a/profiles/audio/transport.h b/profiles/audio/transport.h index 0fe89732f..78c6fa7fb 100644 --- a/profiles/audio/transport.h +++ b/profiles/audio/transport.h @@ -39,3 +39,5 @@ void media_transport_update_volume(struct media_transport *transport, uint8_t volume); void transport_get_properties(struct media_transport *transport, DBusMessageIter *iter); + +uint8_t media_transport_get_device_volume(struct audio_device *dev); -- 2.47.3