summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-01-27 21:58:00 +0200
committerJohan Hedberg <johan.hedberg@nokia.com>2009-01-27 22:06:00 +0200
commit836c502d8adf137c586ffe6a5733d61ba2f57482 (patch)
treeb739b4c59a06697f41c093121069c104ee2dbdf7 /audio
parente7158358e0b780e08b64050033634263a635d001 (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')
-rw-r--r--audio/avdtp.c15
-rw-r--r--audio/avdtp.h2
-rw-r--r--audio/sink.c2
3 files changed, 18 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;
+}
diff --git a/audio/avdtp.h b/audio/avdtp.h
index 906d61ea..197c262d 100644
--- a/audio/avdtp.h
+++ b/audio/avdtp.h
@@ -265,5 +265,7 @@ int avdtp_error_posix_errno(struct avdtp_error *err);
void avdtp_get_peers(struct avdtp *session, bdaddr_t *src, bdaddr_t *dst);
+void avdtp_set_auto_disconnect(struct avdtp *session, gboolean auto_dc);
+
int avdtp_init(const bdaddr_t *src, GKeyFile *config);
void avdtp_exit(const bdaddr_t *src);
diff --git a/audio/sink.c b/audio/sink.c
index a966d2bc..347e3f69 100644
--- a/audio/sink.c
+++ b/audio/sink.c
@@ -425,6 +425,8 @@ static DBusMessage *sink_connect(DBusConnection *conn,
".AlreadyConnected",
"Device Already Connected");
+ avdtp_set_auto_disconnect(sink->session, FALSE);
+
pending = g_new0(struct pending_request, 1);
pending->conn = dbus_connection_ref(conn);
pending->msg = dbus_message_ref(msg);