* [PATCH BlueZ] transport: Fix not being able to initialize volume properly
@ 2022-04-27 20:19 Luiz Augusto von Dentz
2022-04-27 21:27 ` [BlueZ] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2022-04-27 20:19 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
In case AVRCP is connected first and
media_transport_update_device_volume is called without any media_player
being available the volume setting would be lost and Transport.Volume
won't be available, so this introduces btd_device_{set,get}_volume
helpers which is used to store the volume temporarely so
media_player_get_device_volume is able to restore it when the transport
is created.
Fixes: https://github.com/bluez/bluez/issues/335
---
profiles/audio/transport.c | 12 ++++++++++--
src/device.c | 13 +++++++++++++
src/device.h | 3 +++
3 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/profiles/audio/transport.c b/profiles/audio/transport.c
index d158fc97a..5848e4019 100644
--- a/profiles/audio/transport.c
+++ b/profiles/audio/transport.c
@@ -949,6 +949,7 @@ int8_t media_transport_get_device_volume(struct btd_device *dev)
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)
@@ -959,7 +960,8 @@ int8_t media_transport_get_device_volume(struct btd_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,
@@ -970,13 +972,19 @@ 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 38f4993f2..112bcc1f9 100644
--- a/src/device.c
+++ b/src/device.c
@@ -274,6 +274,8 @@ struct btd_device {
guint store_id;
time_t name_resolve_failed_time;
+
+ int8_t volume;
};
static const uint16_t uuid_list[] = {
@@ -4334,6 +4336,7 @@ static struct btd_device *device_new(struct btd_adapter *adapter,
return NULL;
device->tx_power = 127;
+ device->volume = -1;
device->db = gatt_db_new();
if (!device->db) {
@@ -7303,3 +7306,13 @@ void btd_device_cleanup(void)
{
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 071576d6b..9cdc0e68d 100644
--- a/src/device.h
+++ b/src/device.h
@@ -180,3 +180,6 @@ bool btd_device_all_services_allowed(struct btd_device *dev);
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);
--
2.35.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [BlueZ] transport: Fix not being able to initialize volume properly
2022-04-27 20:19 [PATCH BlueZ] transport: Fix not being able to initialize volume properly Luiz Augusto von Dentz
@ 2022-04-27 21:27 ` bluez.test.bot
0 siblings, 0 replies; 2+ messages in thread
From: bluez.test.bot @ 2022-04-27 21:27 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 995 bytes --]
This is automated email and please do not reply to this email!
Dear submitter,
Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=636348
---Test result---
Test Summary:
CheckPatch PASS 1.46 seconds
GitLint PASS 0.95 seconds
Prep - Setup ELL PASS 42.40 seconds
Build - Prep PASS 0.67 seconds
Build - Configure PASS 8.41 seconds
Build - Make PASS 1343.00 seconds
Make Check PASS 11.79 seconds
Make Check w/Valgrind PASS 439.80 seconds
Make Distcheck PASS 226.66 seconds
Build w/ext ELL - Configure PASS 8.55 seconds
Build w/ext ELL - Make PASS 1336.88 seconds
Incremental Build with patchesPASS 0.00 seconds
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-27 21:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 20:19 [PATCH BlueZ] transport: Fix not being able to initialize volume properly Luiz Augusto von Dentz
2022-04-27 21:27 ` [BlueZ] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).