diff options
author | Johan Hedberg <johan.hedberg@nokia.com> | 2009-01-27 21:58:00 +0200 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2009-01-27 22:06:00 +0200 |
commit | 836c502d8adf137c586ffe6a5733d61ba2f57482 (patch) | |
tree | b739b4c59a06697f41c093121069c104ee2dbdf7 /audio/avdtp.c | |
parent | e7158358e0b780e08b64050033634263a635d001 (diff) |
Don't auto-disconnect explicitly created A2DP connections
This patch makes sure that explicitly created connections (remotely
initiated or using AudioSink.Connect()) stay up until explictly
disconnected. The control for this needs to be in the stream timer and
not the disconnect timer since our AVDTP state machine always tries to
keep one stream in configured state (i.e. it should be ok to always
disconnect if we stay too long in IDLE state).
Diffstat (limited to 'audio/avdtp.c')
-rw-r--r-- | audio/avdtp.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/audio/avdtp.c b/audio/avdtp.c index 455f2c69..bf3b79e0 100644 --- a/audio/avdtp.c +++ b/audio/avdtp.c @@ -348,6 +348,9 @@ struct avdtp { avdtp_session_state_t last_state; avdtp_session_state_t state; + /* True if the session should be automatically disconnected */ + gboolean auto_dc; + guint io; int sock; @@ -703,7 +706,7 @@ static void avdtp_sep_set_state(struct avdtp *session, switch (state) { case AVDTP_STATE_OPEN: - if (old_state > AVDTP_STATE_OPEN) + if (old_state > AVDTP_STATE_OPEN && session->auto_dc) stream->idle_timer = g_timeout_add_seconds(STREAM_TIMEOUT, stream_timeout, stream); @@ -2224,6 +2227,7 @@ static struct avdtp *avdtp_get_internal(const bdaddr_t *src, const bdaddr_t *dst bacpy(&session->dst, dst); session->ref = 1; session->state = AVDTP_SESSION_STATE_DISCONNECTED; + session->auto_dc = TRUE; sessions = g_slist_append(sessions, session); @@ -2765,7 +2769,11 @@ static void auth_cb(DBusError *derr, void *user_data) session->buf = g_malloc0(session->mtu); + /* Here we set the disconnect timer so we don't stay in IDLE state + * indefinitely but set auto_dc to FALSE so that when a stream is + * finally opened it doesn't get closed due to a timeout */ set_disconnect_timer(session); + avdtp_set_auto_disconnect(session, FALSE); session->state = AVDTP_SESSION_STATE_CONNECTED; @@ -2971,3 +2979,8 @@ gboolean avdtp_has_stream(struct avdtp *session, struct avdtp_stream *stream) { return g_slist_find(session->streams, stream) ? TRUE : FALSE; } + +void avdtp_set_auto_disconnect(struct avdtp *session, gboolean auto_dc) +{ + session->auto_dc = auto_dc; +} |