a2dp: Fix crash when endpoint respond with an error
Luiz Augusto von Dentz
maintainerPATCH v2 1/4 a2dp: Fix crash when endpoint respond with an error
From: Luiz Augusto von Dentz <[email protected]>
If endpoint respond with an error the callback will be called with size set to -1 not 0.
--- profiles/audio/a2dp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
profiles/audio/a2dp.c +1 -1
@@ -2418,7 +2418,7 @@ static void select_cb(struct a2dp_setup *setup, void *ret, int size)struct avdtp_media_codec_capability *codec;int err; -if (size) { +if (size >=0 ) {caps_add_codec (&setup->caps, setup->sep->codec, ret, size); goto done; }
Signature · 1 line
2.20.1
Luiz Augusto von Dentz
maintainerPATCH v2 2/4 a2dp: Try aborting when switching endpoints
From: Luiz Augusto von Dentz <[email protected]>
If ongoing stream cannot be closed try aborting since the setup may still be ongoing.
--- profiles/audio/a2dp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
profiles/audio/a2dp.c +11 -2
@@ -1257,6 +1257,11 @@ static void abort_cfm(struct avdtp *session, struct avdtp_local_sep *sep,if (!setup)return ; +if (setup->reconfigure) { +g_timeout_add (RECONFIGURE_TIMEOUT , a2dp_reconfigure, setup); +return ; + } +setup_unref (setup); }
@@ -1642,8 +1647,12 @@ static int a2dp_reconfig(struct a2dp_channel *chan, const char *sender, err =avdtp_close (chan->session, tmp->stream, FALSE);if (err <0 ) { -error ("avdtp_close: %s" ,strerror (-err)); - goto fail; + err =avdtp_abort (chan->session, tmp->stream); +if (err <0 ) { +error ("avdtp_abort: %s" , +strerror (-err)); + goto fail; + } } setup->reconfigure = TRUE;
Signature · 1 line
2.20.1
Luiz Augusto von Dentz
maintainerPATCH v2 3/4 a2dp: Update last used on open indication
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
This updates the last used endpoint also when receiving an open request from the remote end.
--- profiles/audio/a2dp.c | 55 +++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-)
profiles/audio/a2dp.c +29 -26
@@ -836,32 +836,6 @@ static void getconf_cfm(struct avdtp *session, struct avdtp_local_sep *sep,DBG ("Source %p: Set_Configuration_Cfm" , sep); } -static gboolean open_ind (struct avdtp *session,struct avdtp_local_sep *sep, -struct avdtp_stream *stream,uint8_t *err, -void *user_data) -{ -struct a2dp_sep *a2dp_sep = user_data; -struct a2dp_setup *setup; - -if (a2dp_sep->type ==AVDTP_SEP_TYPE_SINK ) -DBG ("Sink %p: Open_Ind" , sep); -else -DBG ("Source %p: Open_Ind" , sep); - - setup =a2dp_setup_get (session); -if (!setup) -return FALSE; - - setup->stream = stream; - -if (setup->reconfigure) - setup->reconfigure = FALSE; - -finalize_config (setup); - -return TRUE; -} -static bool match_remote_sep (const void *data,const void *user_data) {const struct a2dp_remote_sep *sep = data;
@@ -916,6 +890,35 @@ static void update_last_used(struct a2dp_channel *chan,store_last_used (chan, rsep); } +static gboolean open_ind (struct avdtp *session,struct avdtp_local_sep *sep, +struct avdtp_stream *stream,uint8_t *err, +void *user_data) +{ +struct a2dp_sep *a2dp_sep = user_data; +struct a2dp_setup *setup; + +if (a2dp_sep->type ==AVDTP_SEP_TYPE_SINK ) +DBG ("Sink %p: Open_Ind" , sep); +else +DBG ("Source %p: Open_Ind" , sep); + + setup =a2dp_setup_get (session); +if (!setup) +return FALSE; + + setup->stream = stream; + +if (!err && setup->chan) +update_last_used (setup->chan, stream); + +if (setup->reconfigure) + setup->reconfigure = FALSE; + +finalize_config (setup); + +return TRUE; +} +static void open_cfm (struct avdtp *session,struct avdtp_local_sep *sep,struct avdtp_stream *stream,struct avdtp_error *err,void *user_data)
Signature · 1 line
2.20.1
Luiz Augusto von Dentz
maintainerPATCH v2 4/4 a2dp: Fix reconfiguring when there multiple devices connected
In reply to Luiz Augusto von DentzFrom: Luiz Augusto von Dentz <[email protected]>
When there are multiple devices connected streams need to be matched with the sessions they belong.
--- profiles/audio/a2dp.c | 4 ++++ 1 file changed, 4 insertions(+)
profiles/audio/a2dp.c +4 -0
@@ -1648,6 +1648,10 @@ static int a2dp_reconfig(struct a2dp_channel *chan, const char *sender, tmp->user_data)))return -EPERM ; +/* Check if stream is for the channel */ +if (!avdtp_has_stream (chan->session, tmp->stream)) +continue ; + err =avdtp_close (chan->session, tmp->stream, FALSE);if (err <0 ) { err =avdtp_abort (chan->session, tmp->stream);
Signature · 1 line
2.20.1