This patch adds a Handsfree Audio Card to the emulator structure and a
function to create it. When the emulator is about to be removed, its
card is also removed.
---
 src/emulator.c |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/emulator.c b/src/emulator.c
index 70505b5..48998f5 100644
--- a/src/emulator.c
+++ b/src/emulator.c
@@ -29,6 +29,9 @@
 
 #include <glib.h>
 
+#define OFONO_API_SUBJECT_TO_CHANGE
+#include <ofono/handsfree-audio.h>
+
 #include "ofono.h"
 #include "common.h"
 #include "hfp.h"
@@ -53,6 +56,7 @@ struct ofono_emulator {
        gboolean clip;
        gboolean ccwa;
        int pns_id;
+       struct ofono_handsfree_card *card;
 };
 
 struct indicator {
@@ -880,6 +884,11 @@ static void emulator_unregister(struct ofono_atom *atom)
 
        g_at_server_unref(em->server);
        em->server = NULL;
+
+       if (em->card) {
+               ofono_handsfree_card_remove(em->card);
+               em->card = NULL;
+       }
 }
 
 void ofono_emulator_register(struct ofono_emulator *em, int fd)
@@ -990,6 +999,13 @@ struct ofono_emulator *ofono_emulator_create(struct 
ofono_modem *modem,
        return em;
 }
 
+int ofono_emulator_create_card(struct ofono_emulator *em, int version)
+{
+       em->card = ofono_handsfree_card_create(0, NULL, NULL);
+
+       return 0;
+}
+
 void ofono_emulator_remove(struct ofono_emulator *em)
 {
        __ofono_atom_free(em->atom);
-- 
1.7.9.5

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

Reply via email to