Diff between 48a962ec6d6de4b1114b874638703918c54d2752 and ea873d1a6ae6b5ee4b75a56998ff0a93649ca226

Changed Files

File Additions Deletions Status
android/Android.mk +1 -0 modified
android/Makefile.am +1 -0 modified
android/client/haltest.c +7 -3 modified
android/client/if-audio.c +67 -0 added
android/client/if-main.h +4 -0 modified

Full Patch

diff --git a/android/Android.mk b/android/Android.mk
index 99882bb..5a55a76 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -126,6 +126,7 @@ LOCAL_SRC_FILES := \
 	client/terminal.c \
 	client/history.c \
 	client/tabcompletion.c \
+	client/if-audio.c \
 	client/if-av.c \
 	client/if-bt.c \
 	client/if-hf.c \
diff --git a/android/Makefile.am b/android/Makefile.am
index f5e8c99..87676cd 100644
--- a/android/Makefile.am
+++ b/android/Makefile.am
@@ -89,6 +89,7 @@ android_haltest_SOURCES = android/client/haltest.c \
 				android/client/if-hh.c \
 				android/client/if-pan.c \
 				android/client/if-sock.c \
+				android/client/if-audio.c \
 				android/hardware/hardware.c \
 				android/hal-utils.h android/hal-utils.c
 
diff --git a/android/client/haltest.c b/android/client/haltest.c
index 7154d27..7c314c0 100644
--- a/android/client/haltest.c
+++ b/android/client/haltest.c
@@ -31,6 +31,7 @@
 #include "history.h"
 
 const struct interface *interfaces[] = {
+	&audio_if,
 	&bluetooth_if,
 	&av_if,
 #if PLATFORM_SDK_VERSION > 17
@@ -393,10 +394,13 @@ static void init(void)
 	};
 	const struct method *m;
 	const char *argv[4];
-	char init_line[] = "bluetooth init";
+	char init_audio[] = "audio init";
+	char init_bt[] = "bluetooth init";
 	uint32_t i;
 
-	process_line(init_line);
+	process_line(init_audio);
+	process_line(init_bt);
+
 	m = get_interface_method("bluetooth", "get_profile_interface");
 
 	for (i = 0; i < NELEM(inames); ++i) {
@@ -405,7 +409,7 @@ static void init(void)
 	}
 
 	/* Init what is available to init */
-	for (i = 1; i < NELEM(interfaces) - 1; ++i) {
+	for (i = 2; i < NELEM(interfaces) - 1; ++i) {
 		m = get_interface_method(interfaces[i]->name, "init");
 		if (m != NULL)
 			m->func(2, argv);
diff --git a/android/client/if-audio.c b/android/client/if-audio.c
new file mode 100644
index 0000000..203e088
--- /dev/null
+++ b/android/client/if-audio.c
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2014 Intel Corporation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "if-main.h"
+#include "../hal-utils.h"
+
+audio_hw_device_t *if_audio = NULL;
+
+static void init_p(int argc, const char **argv)
+{
+	int err;
+	const hw_module_t *module;
+	audio_hw_device_t *device;
+
+	err = hw_get_module_by_class(AUDIO_HARDWARE_MODULE_ID,
+					AUDIO_HARDWARE_MODULE_ID_A2DP, &module);
+	if (err) {
+		haltest_error("hw_get_module_by_class returned %d\n", err);
+		return;
+	}
+
+	err = audio_hw_device_open(module, &device);
+	if (err)
+		haltest_error("audio_hw_device_open returned %d\n", err);
+
+	if_audio = device;
+}
+
+static void cleanup_p(int argc, const char **argv)
+{
+	int err;
+
+	RETURN_IF_NULL(if_audio);
+
+	err = audio_hw_device_close(if_audio);
+	if (err < 0) {
+		haltest_error("audio_hw_device_close returned %d\n", err);
+		return;
+	}
+
+	if_audio = NULL;
+}
+
+static struct method methods[] = {
+	STD_METHOD(init),
+	STD_METHOD(cleanup),
+	END_METHOD
+};
+
+const struct interface audio_if = {
+	.name = "audio",
+	.methods = methods
+};
diff --git a/android/client/if-main.h b/android/client/if-main.h
index 4a5d4cc..0371c3e 100644
--- a/android/client/if-main.h
+++ b/android/client/if-main.h
@@ -28,6 +28,7 @@
 #include <sys/un.h>
 #include <poll.h>
 
+#include <hardware/audio.h>
 #include <hardware/bluetooth.h>
 #include <hardware/bt_av.h>
 #include <hardware/bt_hh.h>
@@ -44,6 +45,8 @@
 #include <hardware/bt_gatt_server.h>
 #endif
 
+extern audio_hw_device_t *if_audio;
+
 /* Interfaces from hal that can be populated during application lifetime */
 extern const bt_interface_t *if_bluetooth;
 extern const btav_interface_t *if_av;
@@ -66,6 +69,7 @@ struct interface {
 	struct method *methods; /* methods available for this interface */
 };
 
+extern const struct interface audio_if;
 extern const struct interface bluetooth_if;
 extern const struct interface av_if;
 #if PLATFORM_SDK_VERSION > 17