Skip to contentSkip to conversation

Check all states before allowing gw connection

PATCH In review Frédéric Dalleau 2 participants 4 messages Sep 23, 2011 – Sep 27, 2011 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 Check all states before allowing gw connection

---
 audio/gateway.c |   10 ++++++++++
 audio/gateway.h |    1 +
 audio/manager.c |    2 +-
 3 files changed, 12 insertions(+), 1 deletions(-)
audio/gateway.c +10 -0
index f3e6c6a..ca44576 100644
@@ -764,6 +764,16 @@ gboolean gateway_is_connected(struct audio_device *dev)
 			dev->gateway->state == GATEWAY_STATE_CONNECTED);
 }
 
+gboolean gateway_is_active(struct audio_device *dev)
+{
+	struct gateway *gw = dev->gateway;
+
+	if (gw->state != GATEWAY_STATE_DISCONNECTED)
+		return TRUE;
+
+	return FALSE;
+}
+
 int gateway_connect_rfcomm(struct audio_device *dev, GIOChannel *io)
 {
 	if (!io)
audio/gateway.h +1 -0
index a8ed2f2..77f5787 100644
@@ -57,6 +57,7 @@ typedef void (*gateway_stream_cb_t) (struct audio_device *dev, GError *err,
 void gateway_set_state(struct audio_device *dev, gateway_state_t new_state);
 void gateway_unregister(struct audio_device *dev);
 struct gateway *gateway_init(struct audio_device *device);
+gboolean gateway_is_active(struct audio_device *dev);
 gboolean gateway_is_connected(struct audio_device *dev);
 int gateway_connect_rfcomm(struct audio_device *dev, GIOChannel *io);
 int gateway_connect_sco(struct audio_device *dev, GIOChannel *chan);
audio/manager.c +1 -1
index 053562e..06d3f0e 100644
@@ -594,7 +594,7 @@ static void hf_io_cb(GIOChannel *chan, gpointer data)
 			goto drop;
 	}
 
-	if (gateway_is_connected(device)) {
+	if (gateway_is_active(device)) {
 		DBG("Refusing new connection since one already exists");
 		goto drop;
 	}
Signature · 1 line
1.7.4.1
#1 lore raw

PATCH 2/3 Remove unneeded checks in gateway_is_connected

---
 audio/gateway.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
audio/gateway.c +6 -2
index ca44576..b98dfba 100644
@@ -760,8 +760,12 @@ struct gateway *gateway_init(struct audio_device *dev)
 
 gboolean gateway_is_connected(struct audio_device *dev)
 {
-	return (dev && dev->gateway &&
-			dev->gateway->state == GATEWAY_STATE_CONNECTED);
+	struct gateway *gw = dev->gateway;
+
+	if (gw->state == GATEWAY_STATE_CONNECTED)
+		return TRUE;
+
+	return FALSE;
 }
 
 gboolean gateway_is_active(struct audio_device *dev)
Signature · 1 line
1.7.4.1
#2 lore raw

PATCH 3/3 Minor style fix

In reply to Frédéric Dalleau
---
 audio/gateway.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)
audio/gateway.c +0 -1
index b98dfba..19c7ee3 100644
@@ -755,7 +755,6 @@ struct gateway *gateway_init(struct audio_device *dev)
 		return NULL;
 
 	return g_new0(struct gateway, 1);
-
 }
 
 gboolean gateway_is_connected(struct audio_device *dev)
Signature · 1 line
1.7.4.1
#3 lore raw
In reply to Frédéric Dalleau

Hi Frédéric,

Quoted 5 lines · Frédéric Dalleau
---
 audio/gateway.c |   10 ++++++++++
 audio/gateway.h |    1 +
 audio/manager.c |    2 +-
 3 files changed, 12 insertions(+), 1 deletions(-)

All three patches applied. Thanks.

Johan