From 3294d4df5f170aabc7663d79b3ca00f6961818b7 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Thu, 5 Mar 2009 10:13:45 -0300 Subject: Set avdtp session watch to low priority. The session watch should be low priority because on old kernels (prior to DEFER_SETUP). This is needed for stream Open & Start because the connection is automatically accepted and makes the remote device to sending the Start command imediately. Since both the stream transport connection and the Start command arrive so close to each other the kernel might wake up bluetoothd at the same time for both. --- audio/avdtp.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/audio/avdtp.c b/audio/avdtp.c index 2b90b0df..c92bf83c 100644 --- a/audio/avdtp.c +++ b/audio/avdtp.c @@ -1903,10 +1903,20 @@ static void avdtp_connect_cb(GIOChannel *chan, GError *err, gpointer user_data) session->buf = g_malloc0(session->imtu); session->state = AVDTP_SESSION_STATE_CONNECTED; - session->io_id = g_io_add_watch(chan, + + /* This watch should be low priority since otherwise the + * connect callback might be dispatched before the session + * callback if the kernel wakes us up at the same time for + * them. This could happen if a headset is very quick in + * sending the Start command after connecting the stream + * transport channel. + */ + session->io_id = g_io_add_watch_full(chan, + G_PRIORITY_LOW, G_IO_IN | G_IO_ERR | G_IO_HUP | G_IO_NVAL, - (GIOFunc) session_cb, session); + (GIOFunc) session_cb, session, + NULL); if (session->stream_setup) { set_disconnect_timer(session); -- cgit