OSDN Git Service

Fix headset never connecting on the first attempt.
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>
Tue, 2 Jun 2009 21:53:06 +0000 (18:53 -0300)
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>
Tue, 2 Jun 2009 21:53:06 +0000 (18:53 -0300)
manager_allow_headset_connection was considering the connection attempt
itself as a connection when it shouldn't.

audio/headset.c
audio/manager.c
audio/manager.h

index ca480c5..9e562da 100644 (file)
@@ -1495,7 +1495,7 @@ static int rfcomm_connect(struct audio_device *dev, headset_stream_cb_t cb,
        GError *err = NULL;
        GIOChannel *io;
 
-       if (!manager_allow_headset_connection(&dev->src))
+       if (!manager_allow_headset_connection(dev))
                return -ECONNREFUSED;
 
        if (hs->rfcomm_ch < 0)
index 7343e6d..7afed76 100644 (file)
@@ -457,7 +457,7 @@ static void ag_confirm(GIOChannel *chan, gpointer data)
        if (!device)
                goto drop;
 
-       if (!manager_allow_headset_connection(&device->src)) {
+       if (!manager_allow_headset_connection(device)) {
                debug("Refusing headset: too many existing connections");
                goto drop;
        }
@@ -1239,7 +1239,7 @@ struct audio_device *manager_get_device(const bdaddr_t *src,
        return dev;
 }
 
-gboolean manager_allow_headset_connection(bdaddr_t *src)
+gboolean manager_allow_headset_connection(struct audio_device *device)
 {
        GSList *l;
        int connected = 0;
@@ -1248,7 +1248,10 @@ gboolean manager_allow_headset_connection(bdaddr_t *src)
                struct audio_device *dev = l->data;
                struct headset *hs = dev->headset;
 
-               if (bacmp(&dev->src, src))
+               if (dev == device)
+                       continue;
+
+               if (bacmp(&dev->src, &device->src))
                        continue;
 
                if (!hs)
index f0e676d..b7e46dd 100644 (file)
@@ -46,4 +46,4 @@ struct audio_device *manager_get_device(const bdaddr_t *src,
                                        const bdaddr_t *dst,
                                        gboolean create);
 
-gboolean manager_allow_headset_connection(bdaddr_t *src);
+gboolean manager_allow_headset_connection(struct audio_device *device);