* [PATCH BlueZ] a2dp: Handle remote SEP disappearing
@ 2021-01-21 1:09 Luiz Augusto von Dentz
2021-01-21 1:59 ` [BlueZ] " bluez.test.bot
0 siblings, 1 reply; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2021-01-21 1:09 UTC (permalink / raw)
To: linux-bluetooth
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Some devices (Sony WH-1000XM4) seems to dinamically change its endpoints
depending on the configuration which may leave behind endpoints loaded
from cache that are no longer valid.
gh-issue: https://github.com/bluez/bluez/issues/85
---
profiles/audio/a2dp.c | 12 +++++++++
profiles/audio/avdtp.c | 55 +++++++++++++++++++++++++++++++++++-------
profiles/audio/avdtp.h | 5 ++++
3 files changed, 63 insertions(+), 9 deletions(-)
diff --git a/profiles/audio/a2dp.c b/profiles/audio/a2dp.c
index a333276e0..624d0d42d 100644
--- a/profiles/audio/a2dp.c
+++ b/profiles/audio/a2dp.c
@@ -1488,6 +1488,8 @@ static void remote_sep_free(void *data)
{
struct a2dp_remote_sep *sep = data;
+ avdtp_remote_sep_set_destroy(sep->sep, NULL, NULL);
+
free(sep->path);
free(sep);
}
@@ -1874,6 +1876,14 @@ static const GDBusPropertyTable sep_properties[] = {
{ }
};
+static void remote_sep_destroy(void *user_data)
+{
+ struct a2dp_remote_sep *sep = user_data;
+
+ if (queue_remove(sep->chan->seps, sep))
+ remove_remote_sep(sep);
+}
+
static void register_remote_sep(void *data, void *user_data)
{
struct avdtp_remote_sep *rsep = data;
@@ -1910,6 +1920,8 @@ static void register_remote_sep(void *data, void *user_data)
DBG("Found remote SEP: %s", sep->path);
+ avdtp_remote_sep_set_destroy(rsep, sep, remote_sep_destroy);
+
done:
queue_push_tail(chan->seps, sep);
}
diff --git a/profiles/audio/avdtp.c b/profiles/audio/avdtp.c
index 1093a3543..b8ef5f682 100644
--- a/profiles/audio/avdtp.c
+++ b/profiles/audio/avdtp.c
@@ -308,8 +308,11 @@ struct avdtp_remote_sep {
uint8_t media_type;
struct avdtp_service_capability *codec;
gboolean delay_reporting;
+ bool discovered;
GSList *caps; /* of type struct avdtp_service_capability */
struct avdtp_stream *stream;
+ avdtp_remote_sep_destroy_t destroy;
+ void *user_data;
};
struct avdtp_local_sep {
@@ -1038,6 +1041,32 @@ static void avdtp_sep_set_state(struct avdtp *session,
stream_free(stream);
}
+static void sep_free(gpointer data)
+{
+ struct avdtp_remote_sep *sep = data;
+
+ if (sep->destroy)
+ sep->destroy(sep->user_data);
+
+ g_slist_free_full(sep->caps, g_free);
+ g_free(sep);
+}
+
+static void remove_disappeared(void *data, void *user_data)
+{
+ struct avdtp_remote_sep *sep = data;
+ struct avdtp *session = user_data;
+
+ if (sep->discovered)
+ return;
+
+ DBG("seid %d disappeared", sep->seid);
+
+ session->seps = g_slist_remove(session->seps, sep);
+
+ sep_free(sep);
+}
+
static void finalize_discovery(struct avdtp *session, int err)
{
struct discover_callback *discover = session->discover;
@@ -1051,6 +1080,9 @@ static void finalize_discovery(struct avdtp *session, int err)
if (discover->id > 0)
g_source_remove(discover->id);
+ if (!err)
+ g_slist_foreach(session->seps, remove_disappeared, session);
+
if (discover->cb)
discover->cb(session, session->seps, err ? &avdtp_err : NULL,
discover->user_data);
@@ -1070,14 +1102,6 @@ static void release_stream(struct avdtp_stream *stream, struct avdtp *session)
avdtp_sep_set_state(session, sep, AVDTP_STATE_IDLE);
}
-static void sep_free(gpointer data)
-{
- struct avdtp_remote_sep *sep = data;
-
- g_slist_free_full(sep->caps, g_free);
- g_free(sep);
-}
-
static void remove_disconnect_timer(struct avdtp *session)
{
if (!session->dc_timer)
@@ -2707,8 +2731,10 @@ static gboolean avdtp_discover_resp(struct avdtp *session,
sep = find_remote_sep(session->seps, resp->seps[i].seid);
if (sep && sep->type == resp->seps[i].type &&
sep->media_type == resp->seps[i].media_type &&
- sep->codec)
+ sep->codec) {
+ sep->discovered = true;
continue;
+ }
if (resp->seps[i].inuse && !stream)
continue;
@@ -2720,6 +2746,7 @@ static gboolean avdtp_discover_resp(struct avdtp *session,
sep->seid = resp->seps[i].seid;
sep->type = resp->seps[i].type;
sep->media_type = resp->seps[i].media_type;
+ sep->discovered = true;
memset(&req, 0, sizeof(req));
req.acp_seid = sep->seid;
@@ -3325,6 +3352,16 @@ struct avdtp_remote_sep *avdtp_register_remote_sep(struct avdtp *session,
return sep;
}
+void avdtp_remote_sep_set_destroy(struct avdtp_remote_sep *sep, void *user_data,
+ avdtp_remote_sep_destroy_t destroy)
+{
+ if (!sep)
+ return;
+
+ sep->user_data = user_data;
+ sep->destroy = destroy;
+}
+
static gboolean process_discover(gpointer data)
{
struct avdtp *session = data;
diff --git a/profiles/audio/avdtp.h b/profiles/audio/avdtp.h
index 7a1c109c2..b29d0621a 100644
--- a/profiles/audio/avdtp.h
+++ b/profiles/audio/avdtp.h
@@ -216,6 +216,11 @@ struct avdtp_remote_sep *avdtp_register_remote_sep(struct avdtp *session,
GSList *caps,
bool delay_reporting);
+typedef void (*avdtp_remote_sep_destroy_t)(void *user_data);
+
+void avdtp_remote_sep_set_destroy(struct avdtp_remote_sep *sep, void *user_data,
+ avdtp_remote_sep_destroy_t destroy);
+
uint8_t avdtp_get_seid(struct avdtp_remote_sep *sep);
uint8_t avdtp_get_type(struct avdtp_remote_sep *sep);
--
2.26.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [BlueZ] a2dp: Handle remote SEP disappearing
2021-01-21 1:09 [PATCH BlueZ] a2dp: Handle remote SEP disappearing Luiz Augusto von Dentz
@ 2021-01-21 1:59 ` bluez.test.bot
2021-01-22 22:01 ` Luiz Augusto von Dentz
0 siblings, 1 reply; 3+ messages in thread
From: bluez.test.bot @ 2021-01-21 1:59 UTC (permalink / raw)
To: linux-bluetooth, luiz.dentz
[-- Attachment #1: Type: text/plain, Size: 557 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=418663
---Test result---
##############################
Test: CheckPatch - PASS
##############################
Test: CheckGitLint - PASS
##############################
Test: CheckBuild - PASS
##############################
Test: MakeCheck - PASS
---
Regards,
Linux Bluetooth
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [BlueZ] a2dp: Handle remote SEP disappearing
2021-01-21 1:59 ` [BlueZ] " bluez.test.bot
@ 2021-01-22 22:01 ` Luiz Augusto von Dentz
0 siblings, 0 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2021-01-22 22:01 UTC (permalink / raw)
To: linux-bluetooth@vger.kernel.org
Hi,
On Wed, Jan 20, 2021 at 5:59 PM <bluez.test.bot@gmail.com> wrote:
>
> 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=418663
>
> ---Test result---
>
> ##############################
> Test: CheckPatch - PASS
>
> ##############################
> Test: CheckGitLint - PASS
>
> ##############################
> Test: CheckBuild - PASS
>
> ##############################
> Test: MakeCheck - PASS
>
>
>
> ---
> Regards,
> Linux Bluetooth
Pushed.
--
Luiz Augusto von Dentz
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-01-22 22:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-21 1:09 [PATCH BlueZ] a2dp: Handle remote SEP disappearing Luiz Augusto von Dentz
2021-01-21 1:59 ` [BlueZ] " bluez.test.bot
2021-01-22 22:01 ` Luiz Augusto von Dentz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox