linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Check all states before allowing gw connection
@ 2011-09-23 12:59 Frédéric Dalleau
  2011-09-23 12:59 ` [PATCH 2/3] Remove unneeded checks in gateway_is_connected Frédéric Dalleau
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Frédéric Dalleau @ 2011-09-23 12:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Frédéric Dalleau

---
 audio/gateway.c |   10 ++++++++++
 audio/gateway.h |    1 +
 audio/manager.c |    2 +-
 3 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/audio/gateway.c b/audio/gateway.c
index f3e6c6a..ca44576 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -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)
diff --git a/audio/gateway.h b/audio/gateway.h
index a8ed2f2..77f5787 100644
--- a/audio/gateway.h
+++ b/audio/gateway.h
@@ -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);
diff --git a/audio/manager.c b/audio/manager.c
index 053562e..06d3f0e 100644
--- a/audio/manager.c
+++ b/audio/manager.c
@@ -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;
 	}
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] Remove unneeded checks in gateway_is_connected
  2011-09-23 12:59 [PATCH 1/3] Check all states before allowing gw connection Frédéric Dalleau
@ 2011-09-23 12:59 ` Frédéric Dalleau
  2011-09-23 12:59 ` [PATCH 3/3] Minor style fix Frédéric Dalleau
  2011-09-27  9:31 ` [PATCH 1/3] Check all states before allowing gw connection Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Frédéric Dalleau @ 2011-09-23 12:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Frédéric Dalleau

---
 audio/gateway.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/audio/gateway.c b/audio/gateway.c
index ca44576..b98dfba 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -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)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] Minor style fix
  2011-09-23 12:59 [PATCH 1/3] Check all states before allowing gw connection Frédéric Dalleau
  2011-09-23 12:59 ` [PATCH 2/3] Remove unneeded checks in gateway_is_connected Frédéric Dalleau
@ 2011-09-23 12:59 ` Frédéric Dalleau
  2011-09-27  9:31 ` [PATCH 1/3] Check all states before allowing gw connection Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Frédéric Dalleau @ 2011-09-23 12:59 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Frédéric Dalleau

---
 audio/gateway.c |    1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/audio/gateway.c b/audio/gateway.c
index b98dfba..19c7ee3 100644
--- a/audio/gateway.c
+++ b/audio/gateway.c
@@ -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)
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] Check all states before allowing gw connection
  2011-09-23 12:59 [PATCH 1/3] Check all states before allowing gw connection Frédéric Dalleau
  2011-09-23 12:59 ` [PATCH 2/3] Remove unneeded checks in gateway_is_connected Frédéric Dalleau
  2011-09-23 12:59 ` [PATCH 3/3] Minor style fix Frédéric Dalleau
@ 2011-09-27  9:31 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2011-09-27  9:31 UTC (permalink / raw)
  To: Frédéric Dalleau; +Cc: linux-bluetooth

Hi Frédéric,

On Fri, Sep 23, 2011, Frédéric Dalleau wrote:
> ---
>  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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-27  9:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-23 12:59 [PATCH 1/3] Check all states before allowing gw connection Frédéric Dalleau
2011-09-23 12:59 ` [PATCH 2/3] Remove unneeded checks in gateway_is_connected Frédéric Dalleau
2011-09-23 12:59 ` [PATCH 3/3] Minor style fix Frédéric Dalleau
2011-09-27  9:31 ` [PATCH 1/3] Check all states before allowing gw connection Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).