avdtp: Fix always destroying session immediatelly
Luiz Augusto von Dentz
maintainerPATCH 1/1 avdtp: Fix always destroying session immediatelly
From: Luiz Augusto von Dentz <[email protected]>
In case the remote device sent a close/abort the session shall not be free immediatelly as the remote may want to reconfigure the stream.
--- profiles/audio/avdtp.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
profiles/audio/avdtp.c +18 -5
@@ -412,6 +412,7 @@ struct avdtp {struct pending_req *req;guint dc_timer; +int dc_timeout;/* Attempt stream setup instead of disconnecting */ gboolean stream_setup;
@@ -1152,10 +1153,12 @@ static void set_disconnect_timer(struct avdtp *session)if (session->dc_timer)remove_disconnect_timer (session); -if (!session->stream_setup && !session->streams) +DBG ("timeout %d" , session->dc_timeout); + +if (!session->dc_timeout) session->dc_timer =g_idle_add (disconnect_timeout, session);else - session->dc_timer =g_timeout_add_seconds (DISCONNECT_TIMEOUT , + session->dc_timer =g_timeout_add_seconds (session->dc_timeout, disconnect_timeout, session); }
@@ -1797,6 +1800,8 @@ static gboolean avdtp_close_cmd(struct avdtp *session, uint8_t transaction,avdtp_sep_set_state (session, sep,AVDTP_STATE_CLOSING ); + session->dc_timeout =DISCONNECT_TIMEOUT ; +if (!avdtp_send (session, transaction,AVDTP_MSG_TYPE_ACCEPT ,AVDTP_CLOSE ,NULL ,0 ))return FALSE;
@@ -1893,8 +1898,10 @@ static gboolean avdtp_abort_cmd(struct avdtp *session, uint8_t transaction, ret =avdtp_send (session, transaction,AVDTP_MSG_TYPE_ACCEPT ,AVDTP_ABORT ,NULL ,0 ); -if (ret) +if (ret) {avdtp_sep_set_state (session, sep,AVDTP_STATE_ABORTING ); + session->dc_timeout =DISCONNECT_TIMEOUT ; + }return ret; }
@@ -2377,6 +2384,8 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,* with respect to the disconnect timer */ session->stream_setup = TRUE; + session->dc_timeout =DISCONNECT_TIMEOUT ; +avdtp_connect_cb (chan,NULL , session);return session;
@@ -3512,8 +3521,10 @@ int avdtp_close(struct avdtp *session, struct avdtp_stream *stream, ret =send_request (session, FALSE, stream,AVDTP_CLOSE , &req,sizeof (req)); -if (ret ==0 ) +if (ret ==0 ) { stream->close_int = TRUE; + session->dc_timeout =0 ; + }return ret; }
@@ -3561,8 +3572,10 @@ int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream) ret =send_request (session, TRUE, stream,AVDTP_ABORT , &req,sizeof (req)); -if (ret ==0 ) +if (ret ==0 ) { stream->abort_int = TRUE; + session->dc_timeout =0 ; + }return ret; }
Signature · 1 line
2.17.2
Hi,
Quoted 91 lines · Luiz Augusto von Dentz
From: Luiz Augusto von Dentz <[email protected]>
In case the remote device sent a close/abort the session shall not be free immediatelly as the remote may want to reconfigure the stream.
--- profiles/audio/avdtp.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)profiles/audio/avdtp.c +18
-6@@ -412,6 +412,7 @@ struct avdtp {struct pending_req *req;guint dc_timer; +int dc_timeout;/* Attempt stream setup instead of disconnecting */ gboolean stream_setup;@@ -1152,10 +1153,12 @@ static void set_disconnect_timer(struct avdtp *session)if (session->dc_timer)remove_disconnect_timer (session); -if (!session->stream_setup && !session->streams) +DBG ("timeout %d" , session->dc_timeout); + +if (!session->dc_timeout) session->dc_timer =g_idle_add (disconnect_timeout, session);else - session->dc_timer =g_timeout_add_seconds (DISCONNECT_TIMEOUT , + session->dc_timer =g_timeout_add_seconds (session->dc_timeout, disconnect_timeout, session); }@@ -1797,6 +1800,8 @@ static gboolean avdtp_close_cmd(struct avdtp *session, uint8_t transaction,avdtp_sep_set_state (session, sep,AVDTP_STATE_CLOSING ); + session->dc_timeout =DISCONNECT_TIMEOUT ; +if (!avdtp_send (session, transaction,AVDTP_MSG_TYPE_ACCEPT ,AVDTP_CLOSE ,NULL ,0 ))return FALSE;@@ -1893,8 +1898,10 @@ static gboolean avdtp_abort_cmd(struct avdtp *session, uint8_t transaction, ret =avdtp_send (session, transaction,AVDTP_MSG_TYPE_ACCEPT ,AVDTP_ABORT ,NULL ,0 ); -if (ret) +if (ret) {avdtp_sep_set_state (session, sep,AVDTP_STATE_ABORTING ); + session->dc_timeout =DISCONNECT_TIMEOUT ; + }return ret; }@@ -2377,6 +2384,8 @@ struct avdtp *avdtp_new(GIOChannel *chan, struct btd_device *device,* with respect to the disconnect timer */ session->stream_setup = TRUE; + session->dc_timeout =DISCONNECT_TIMEOUT ; +avdtp_connect_cb (chan,NULL , session);return session;@@ -3512,8 +3521,10 @@ int avdtp_close(struct avdtp *session, struct avdtp_stream *stream, ret =send_request (session, FALSE, stream,AVDTP_CLOSE , &req,sizeof (req)); -if (ret ==0 ) +if (ret ==0 ) { stream->close_int = TRUE; + session->dc_timeout =0 ; + }return ret; }@@ -3561,8 +3572,10 @@ int avdtp_abort(struct avdtp *session, struct avdtp_stream *stream) ret =send_request (session, TRUE, stream,AVDTP_ABORT , &req,sizeof (req)); -if (ret ==0 ) +if (ret ==0 ) { stream->abort_int = TRUE; + session->dc_timeout =0 ; + }return ret; } --
Quoted 1 line
2.17.2
Applied.
Signature · 1 line
Luiz Augusto von Dentz