From 77c1d7b9ca0e99693fd084f5541fb175f3002e6b Mon Sep 17 00:00:00 2001 From: Johan Hedberg Date: Wed, 6 Jun 2007 09:12:42 +0000 Subject: Properly handle a SCO connect() succeeding on the first try --- audio/headset.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'audio') diff --git a/audio/headset.c b/audio/headset.c index 78579b5e..a3921d36 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -1325,6 +1325,7 @@ static DBusHandlerResult hs_play(DBusConnection *conn, DBusMessage *msg, struct headset *hs = device->headset; struct sockaddr_sco addr; struct pending_connect *c; + gboolean do_callback = FALSE; int sk, err; if (hs->state < HEADSET_STATE_CONNECTED) @@ -1386,19 +1387,19 @@ static DBusHandlerResult hs_play(DBusConnection *conn, DBusMessage *msg, } debug("SCO connect in progress"); - - hs->state = HEADSET_STATE_PLAY_IN_PROGRESS; - g_io_add_watch(c->io, G_IO_OUT | G_IO_NVAL, (GIOFunc) sco_connect_cb, device); } else { debug("SCO connect succeeded with first try"); - hs->state = HEADSET_STATE_PLAY_IN_PROGRESS; - sco_connect_cb(c->io, G_IO_OUT, device); + do_callback = TRUE; } + hs->state = HEADSET_STATE_PLAY_IN_PROGRESS; hs->pending_connect = c; + if (do_callback) + sco_connect_cb(c->io, G_IO_OUT, device); + return 0; failed: -- cgit