diff --git a/audio/main.c b/audio/main.c
index 5c751af..a48c8b8 100644
--- a/audio/main.c
+++ b/audio/main.c
if (device->headset) {
if (headset_get_state(device) < HEADSET_STATE_CONNECTED) {
DBG("Refusing SCO from non-connected headset");
- goto drop;
+ goto gateway;
}
if (!headset_get_hfp_active(device)) {
goto drop;
headset_set_state(device, HEADSET_STATE_PLAYING);
- } else if (device->gateway) {
+ goto connect;
+ }
+
+gateway:
+ if (device->gateway) {
if (!gateway_is_connected(device)) {
DBG("Refusing SCO from non-connected AG");
goto drop;
} else
goto drop;
+connect:
sk = g_io_channel_unix_get_fd(chan);
fcntl(sk, F_SETFL, 0);