---
 plugins/hsp_ag.c |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/plugins/hsp_ag.c b/plugins/hsp_ag.c
index 5a60269..73050aa 100644
--- a/plugins/hsp_ag.c
+++ b/plugins/hsp_ag.c
@@ -92,10 +92,30 @@ static const gchar *hsp_record =
 " </attribute>\n"
 "</record>\n";
 
+static gboolean sco_unregister_cb(GIOChannel *channel,
+                                       GIOCondition cond, gpointer data)
+{
+       struct sco *sco = data;
+
+       if (cond & (G_IO_NVAL | G_IO_ERR | G_IO_HUP)) {
+               sco_unregister_server(sco);
+               return FALSE;
+       }
+
+       return TRUE;
+}
+
+static void audio_connect_cb(struct ofono_emulator *em, void *data)
+{
+       struct sco *sco = data;
+       sco_connect(sco);
+}
+
 static void connect_cb(GIOChannel *channel, GError *err, gpointer data)
 {      int fd;
        struct ofono_emulator *em;
        struct ofono_modem *modem;
+       struct sco *sco;
 
        /* Pick the first powered modem */
        modem = modems->data;
@@ -110,6 +130,13 @@ static void connect_cb(GIOChannel *channel, GError *err, 
gpointer data)
        ofono_emulator_register(em, fd);
 
        g_io_channel_set_close_on_unref(channel, FALSE);
+
+       sco = sco_register_server(channel);
+
+       ofono_emulator_set_audio_connect_handler(em, audio_connect_cb, sco);
+
+       g_io_add_watch(channel, G_IO_HUP | G_IO_ERR | G_IO_NVAL,
+                                               sco_unregister_cb, sco);
 }
 
 static void voicecall_watch(struct ofono_atom *atom,
-- 
1.7.1

_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono

Reply via email to