This patch adds the Handsfree Audio Card registration when the service
level connection is established.
---
include/handsfree-audio.h | 1 +
plugins/hfp_hf_bluez5.c | 4 ++++
src/handsfree-audio.c | 41 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+)
diff --git a/include/handsfree-audio.h b/include/handsfree-audio.h
index d6e2d0d..0572965 100644
--- a/include/handsfree-audio.h
+++ b/include/handsfree-audio.h
@@ -30,6 +30,7 @@ extern "C" {
void ofono_handsfree_audio_ref(void);
void ofono_handsfree_audio_unref(void);
+char *ofono_handsfree_card_create(const char *remote);
#ifdef __cplusplus
}
diff --git a/plugins/hfp_hf_bluez5.c b/plugins/hfp_hf_bluez5.c
index 7057d71..eb2648e 100644
--- a/plugins/hfp_hf_bluez5.c
+++ b/plugins/hfp_hf_bluez5.c
@@ -46,6 +46,7 @@
#include <ofono/netreg.h>
#include <ofono/voicecall.h>
#include <ofono/call-volume.h>
+#include <ofono/handsfree-audio.h>
#include <ofono/handsfree.h>
#include <drivers/hfpmodem/slc.h>
@@ -61,6 +62,7 @@
struct hfp {
struct hfp_slc_info info;
DBusMessage *msg;
+ char *card;
};
static GDBusClient *bluez = NULL;
@@ -78,6 +80,7 @@ static void slc_established(gpointer userdata)
{
struct ofono_modem *modem = userdata;
struct hfp *hfp = ofono_modem_get_data(modem);
+ const char *remote = ofono_modem_get_string(modem, "Remote");
DBusMessage *msg;
ofono_modem_set_powered(modem, TRUE);
@@ -88,6 +91,7 @@ static void slc_established(gpointer userdata)
hfp->msg = NULL;
ofono_info("Service level connection established");
+ hfp->card = ofono_handsfree_card_create(remote);
}
static void slc_failed(gpointer userdata)
diff --git a/src/handsfree-audio.c b/src/handsfree-audio.c
index 4e2cf93..d4d9796 100644
--- a/src/handsfree-audio.c
+++ b/src/handsfree-audio.c
@@ -35,6 +35,7 @@
#define HFP_AUDIO_MANAGER_INTERFACE OFONO_SERVICE ".HandsfreeAudioManager"
#define HFP_AUDIO_AGENT_INTERFACE OFONO_SERVICE ".HandsfreeAudioAgent"
+#define HFP_AUDIO_CARD_INTERFACE OFONO_SERVICE ".HandsfreeAudioCard"
/* Supported agent codecs */
enum hfp_codec {
@@ -50,6 +51,10 @@ struct agent {
guint watch;
};
+struct audio_card {
+ char *remote;
+};
+
static struct agent *agent = NULL;
static int ref_count = 0;
@@ -205,6 +210,42 @@ void ofono_handsfree_audio_unref(void)
}
}
+static DBusMessage *card_get_properties(DBusConnection *conn,
+ DBusMessage *msg, void *user_data)
+{
+ return __ofono_error_not_implemented(msg);
+}
+
+static const GDBusMethodTable card_methods[] = {
+ { GDBUS_METHOD("GetProperties",
+ NULL, GDBUS_ARGS({ "properties", "a{sv}" }),
+ card_get_properties) },
+ { }
+};
+
+char *ofono_handsfree_card_create(const char *remote)
+{
+ static int audio_card_id = 0;
+ struct audio_card *card;
+ char *path;
+
+ path = g_strdup_printf("/device%d", audio_card_id++);
+ card = g_new0(struct audio_card, 1);
+
+ if (!g_dbus_register_interface(ofono_dbus_get_connection(), path,
+ HFP_AUDIO_CARD_INTERFACE, card_methods,
+ NULL, NULL, card, NULL)) {
+ g_free(path);
+ g_free(card);
+ return NULL;
+ }
+
+ card->remote = g_strdup(remote);
+ DBG("Audio Card added: %s", path);
+
+ return path;
+}
+
int __ofono_handsfree_audio_manager_init(void)
{
return 0;
--
1.7.11.7
_______________________________________________
ofono mailing list
[email protected]
http://lists.ofono.org/listinfo/ofono