[pulseaudio-discuss] [PATCH 12/17] bluetooth: Implement org.ofono.HandsfreeAudioAgent.NewConnection()
Luiz Augusto von Dentz
luiz.dentz at gmail.com
Fri Aug 22 07:04:57 PDT 2014
From: João Paulo Rechi Vita <jprvita at openbossa.org>
---
src/modules/bluetooth/backend-ofono.c | 31 +++++++++++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/modules/bluetooth/backend-ofono.c b/src/modules/bluetooth/backend-ofono.c
index 1fd56a1..56a1944 100644
--- a/src/modules/bluetooth/backend-ofono.c
+++ b/src/modules/bluetooth/backend-ofono.c
@@ -512,7 +512,10 @@ static DBusMessage *hf_audio_agent_release(DBusConnection *c, DBusMessage *m, vo
static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage *m, void *data) {
DBusMessage *r;
- const char *sender;
+ const char *sender, *path;
+ int fd;
+ uint8_t codec;
+ hf_audio_card *card;
pa_bluetooth_backend *backend = data;
pa_assert(backend);
@@ -523,7 +526,31 @@ static DBusMessage *hf_audio_agent_new_connection(DBusConnection *c, DBusMessage
return r;
}
- r = dbus_message_new_error(m, "org.ofono.Error.NotImplemented", "Operation is not implemented");
+ if (dbus_message_get_args(m, NULL,
+ DBUS_TYPE_OBJECT_PATH, &path,
+ DBUS_TYPE_UNIX_FD, &fd,
+ DBUS_TYPE_BYTE, &codec,
+ DBUS_TYPE_INVALID) == FALSE) {
+ pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
+ return r;
+ }
+
+ card = pa_hashmap_get(backend->cards, path);
+ if (!card || codec != HFP_AUDIO_CODEC_CVSD || card->transport->state == PA_BLUETOOTH_TRANSPORT_STATE_PLAYING) {
+ pa_log_warn("New audio connection invalid arguments (path=%s fd=%d, codec=%d)", path, fd, codec);
+ pa_assert_se(r = dbus_message_new_error(m, "org.ofono.Error.InvalidArguments", "Invalid arguments in method call"));
+ return r;
+ }
+
+ pa_log_debug("New audio connection on card %s (fd=%d, codec=%d)", path, fd, codec);
+
+ card->fd = fd;
+ card->transport->codec = codec;
+ card->transport->state = PA_BLUETOOTH_TRANSPORT_STATE_PLAYING;
+ pa_hook_fire(pa_bluetooth_discovery_hook(backend->discovery, PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED), card->transport);
+
+ pa_assert_se(r = dbus_message_new_method_return(m));
+
return r;
}
--
1.9.3
More information about the pulseaudio-discuss
mailing list