diff options
author | Forrest Zhao <forrest.zhao@intel.com> | 2009-04-21 13:49:52 +0100 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2009-04-21 13:49:52 +0100 |
commit | b13f02db1a13cb693ba9c1fe1d80e70cf4953e32 (patch) | |
tree | 13804af15efecec3286c0e0ebc67e377f47b57e7 /audio/main.c | |
parent | e050cc3d1458116cad6f4182c81ba7d31949857c (diff) | |
download | bluez-b13f02db1a13cb693ba9c1fe1d80e70cf4953e32.tar.gz |
re-use the sco_server initiated by audio plugin
Diffstat (limited to 'audio/main.c')
-rw-r--r-- | audio/main.c | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/audio/main.c b/audio/main.c index 853a033b..4e5eda2f 100644 --- a/audio/main.c +++ b/audio/main.c @@ -45,6 +45,7 @@ #include "unix.h" #include "headset.h" #include "manager.h" +#include "gateway.h" static GIOChannel *sco_server = NULL; @@ -94,24 +95,37 @@ static void sco_server_cb(GIOChannel *chan, GError *err, gpointer data) if (!device) goto drop; - if (headset_get_state(device) < HEADSET_STATE_CONNECTED) { - debug("Refusing SCO from non-connected headset"); + if (device->headset) { + if (headset_get_state(device) < HEADSET_STATE_CONNECTED) { + debug("Refusing SCO from non-connected headset"); + goto drop; + } + + if (!get_hfp_active(device)) { + error("Refusing non-HFP SCO connect attempt from %s", + addr); + goto drop; + } + + if (headset_connect_sco(device, chan) < 0) + goto drop; + + headset_set_state(device, HEADSET_STATE_PLAYING); + } else if (device->gateway) { + if (!gateway_is_connected(device)) { + debug("Refusing SCO from non-connected AG"); + goto drop; + } + + if (gateway_connect_sco(device, chan) < 0) + goto drop; + } else goto drop; - } - - if (!get_hfp_active(device)) { - error("Refusing non-HFP SCO connect attempt from %s", addr); - goto drop; - } sk = g_io_channel_unix_get_fd(chan); fcntl(sk, F_SETFL, 0); - if (headset_connect_sco(device, chan) < 0) - goto drop; - debug("Accepted SCO connection from %s", addr); - headset_set_state(device, HEADSET_STATE_PLAYING); return; |