Check all states before allowing gw connection
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
@@ -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
@@ -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
@@ -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
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
@@ -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
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
@@ -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
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