Blame SOURCES/bluez-avdtp-fix-removing-all-seps-when-loading-from-cache.patch

ee2351
From 28ddec8d6b829e002fa268c07b71e4c564ba9e16 Mon Sep 17 00:00:00 2001
ee2351
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
ee2351
Date: Thu, 11 Mar 2021 07:36:07 -0800
ee2351
Subject: [PATCH] avdtp: Fix removing all remote SEPs when loading from cache
ee2351
ee2351
If avdtp_discover is called after cache has been loaded it end up
ee2351
removing all remote SEPs as they have not been discovered yet.
ee2351
ee2351
Fixes: https://github.com/bluez/bluez/issues/102
ee2351
---
ee2351
 profiles/audio/avdtp.c | 16 ++++++++++++----
ee2351
 1 file changed, 12 insertions(+), 4 deletions(-)
ee2351
ee2351
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
ee2351
index 088ca58b3..1d5871c62 100644
ee2351
--- a/profiles/audio/avdtp.c
ee2351
+++ b/profiles/audio/avdtp.c
ee2351
@@ -3381,10 +3381,18 @@ int avdtp_discover(struct avdtp *session, avdtp_discover_cb_t cb,
ee2351
 	session->discover = g_new0(struct discover_callback, 1);
ee2351
 
ee2351
 	if (session->seps) {
ee2351
-		session->discover->cb = cb;
ee2351
-		session->discover->user_data = user_data;
ee2351
-		session->discover->id = g_idle_add(process_discover, session);
ee2351
-		return 0;
ee2351
+		struct avdtp_remote_sep *sep = session->seps->data;
ee2351
+
ee2351
+		/* Check that SEP have been discovered as it may be loaded from
ee2351
+		 * cache.
ee2351
+		 */
ee2351
+		if (sep->discovered) {
ee2351
+			session->discover->cb = cb;
ee2351
+			session->discover->user_data = user_data;
ee2351
+			session->discover->id = g_idle_add(process_discover,
ee2351
+								session);
ee2351
+			return 0;
ee2351
+		}
ee2351
 	}
ee2351
 
ee2351
 	err = send_request(session, FALSE, NULL, AVDTP_DISCOVER, NULL, 0);
ee2351