Skip to contentSkip to conversation

android: Fix not including shared/queue.c in A2DP plugin

PATCH In review Luiz Augusto von Dentz 1 participant 8 messages Aug 11, 2014 Bluetooth drivers

lore
Share & tools
lore

Luiz Augusto von Dentz

author maintainer
#0 lore raw

PATCH v2 1/7 android: Fix not including shared/queue.c in A2DP plugin

From: Luiz Augusto von Dentz <[email protected]>

This can cause the followin error:
audio.a2dp.default.so: undefined symbol: queue_foreach
---
v2: Rebase properly

 android/Makefile.am | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
android/Makefile.am +3 -1
index ac3a766..263a506 100644
@@ -198,7 +198,9 @@ android_audio_a2dp_default_la_SOURCES = android/audio-msg.h \
 					android/hardware/audio.h \
 					android/hardware/audio_effect.h \
 					android/hardware/hardware.h \
-					android/system/audio.h
+					android/system/audio.h \
+					src/shared/queue.h \
+					src/shared/queue.c
 
 android_audio_sco_default_la_SOURCES = android/hal-log.h \
 					android/sco-msg.h \
Signature · 1 line
1.9.3
author maintainer
#1 lore raw

PATCH v2 2/7 android/tester: Load audio module

From: Luiz Augusto von Dentz <[email protected]>

This is necessary to be able to do A2DP tests.

---
 android/tester-main.c | 11 ++++++++++-
 android/tester-main.h |  2 ++
 2 files changed, 12 insertions(+), 1 deletion(-)
android/tester-main.c +10 -1
index a9ccfcd..7d17470 100644
@@ -1169,6 +1169,15 @@ static bool setup_base(struct test_data *data)
 
 	close(signal_fd[0]);
 
+	err = hw_get_module_by_class(AUDIO_HARDWARE_MODULE_ID,
+					AUDIO_HARDWARE_MODULE_ID_A2DP, &module);
+	if (err)
+		return false;
+
+	err = audio_hw_device_open(module, &data->audio);
+	if (err)
+		return false;
+
 	err = hw_get_module(BT_HARDWARE_MODULE_ID, &module);
 	if (err)
 		return false;
@@ -1187,7 +1196,6 @@ static bool setup_base(struct test_data *data)
 	if (!(data->steps = queue_new()))
 		return false;
 
-
 	return true;
 }
 
@@ -1418,6 +1426,7 @@ static void teardown(const void *test_data)
 	}
 
 	data->device->close(data->device);
+	audio_hw_device_close(data->audio);
 
 	if (!data->bluetoothd_pid)
 		tester_teardown_complete();
android/tester-main.h +2 -0
index bdf54b2..ddca69c 100644
@@ -43,6 +43,7 @@
 #include "src/shared/queue.h"
 
 #include <hardware/hardware.h>
+#include <hardware/audio.h>
 #include <hardware/bluetooth.h>
 #include <hardware/bt_sock.h>
 #include <hardware/bt_hh.h>
@@ -279,6 +280,7 @@ typedef enum {
 
 struct test_data {
 	struct mgmt *mgmt;
+	audio_hw_device_t *audio;
 	struct hw_device_t *device;
 	struct hciemu *hciemu;
 	enum hciemu_type hciemu_type;
Signature · 1 line
1.9.3
author maintainer
#2 lore raw

PATCH v2 3/7 android/tester: Add A2DP init - Success test case

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/Makefile.am   |  1 +
 android/tester-a2dp.c | 48 +++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.h |  4 ++++
 4 files changed, 109 insertions(+)
 create mode 100644 android/tester-a2dp.c
android/Makefile.am +1 -0
index 263a506..4b93c5b 100644
@@ -159,6 +159,7 @@ android_android_tester_SOURCES = emulator/btdev.h emulator/btdev.c \
 				android/tester-hidhost.c \
 				android/tester-pan.c \
 				android/tester-hdp.c \
+				android/tester-a2dp.c \
 				android/tester-gatt.c \
 				android/tester-main.h android/tester-main.c
 
android/tester-a2dp.c new file +48 -0

48 lines not on this page · raw message

android/tester-main.c +56 -0

86 lines not on this page · raw message

android/tester-main.h +4 -0
index ddca69c..2cefe5c 100644
@@ -49,6 +49,7 @@
 #include <hardware/bt_hh.h>
 #include <hardware/bt_pan.h>
 #include <hardware/bt_hl.h>
+#include <hardware/bt_av.h>
 #include <hardware/bt_gatt.h>
 #include <hardware/bt_gatt_client.h>
 #include <hardware/bt_gatt_server.h>
@@ -290,6 +291,7 @@ struct test_data {
 	const bthh_interface_t *if_hid;
 	const btpan_interface_t *if_pan;
 	const bthl_interface_t *if_hdp;
+	const btav_interface_t *if_a2dp;
 	const btgatt_interface_t *if_gatt;
 
 	const void *test_data;
@@ -401,6 +403,8 @@ struct queue *get_pan_tests(void);
 void remove_pan_tests(void);
 struct queue *get_hdp_tests(void);
 void remove_hdp_tests(void);
+struct queue *get_a2dp_tests(void);
+void remove_a2dp_tests(void);
 struct queue *get_gatt_tests(void);
 void remove_gatt_tests(void);
 
Signature · 1 line
1.9.3
author maintainer
#3 lore raw

PATCH v2 4/7 android/tester: Add A2DP connect - Success test case

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/tester-a2dp.c | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.c |  12 ++++++
 android/tester-main.h |   8 ++++
 3 files changed, 134 insertions(+)
android/tester-a2dp.c +114 -0
index d2b6516..a86dcec 100644
@@ -18,15 +18,129 @@
 #include <stdbool.h>
 
 #include "emulator/bthost.h"
+#include "src/shared/util.h"
+
 #include "tester-main.h"
 #include "android/utils.h"
 
 static struct queue *list;
 
+struct emu_cid_data {
+	uint16_t handle;
+	uint16_t cid;
+};
+
+static struct emu_cid_data cid_data;
+
+static const uint8_t req_dsc[] = { 0x00, 0x01 };
+static const uint8_t rsp_dsc[] = { 0x02, 0x01, 0x04, 0x08 };
+static const uint8_t req_get[] = { 0x10, 0x02, 0x04 };
+static const uint8_t rsp_get[] = { 0x12, 0x02, 0x01, 0x00, 0x07, 0x06, 0x00,
+						0x00, 0xff, 0xff, 0x02, 0x40 };
+static const uint8_t req_cfg[] = { 0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07,
+					0x06, 0x00, 0x00, 0x21, 0x15, 0x02,
+					0x40 };
+static const uint8_t rsp_cfg[] = { 0x22, 0x03 };
+static const uint8_t req_open[] = { 0x30, 0x06, 0x04 };
+static const uint8_t rsp_open[] = { 0x32, 0x06 };
+
+const struct pdu {
+	const uint8_t *req;
+	size_t req_len;
+	const uint8_t *rsp;
+	size_t rsp_len;
+} pdus[] = {
+	{ req_dsc, sizeof(req_dsc), rsp_dsc, sizeof(rsp_dsc) },
+	{ req_get, sizeof(req_get), rsp_get, sizeof(rsp_get) },
+	{ req_cfg, sizeof(req_cfg), rsp_cfg, sizeof(rsp_cfg) },
+	{ req_open, sizeof(req_open), rsp_open, sizeof(rsp_open) },
+	{ },
+};
+
+static void print_data(const char *str, void *user_data)
+{
+	tester_debug("a2dp: %s", str);
+}
+
+static void a2dp_cid_hook_cb(const void *data, uint16_t len, void *user_data)
+{
+	struct emu_cid_data *cid_data = user_data;
+	struct test_data *t_data = tester_get_data();
+	struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
+	int i;
+
+	util_hexdump('>', data, len, print_data, NULL);
+
+	for (i = 0; pdus[i].req; i++) {
+		if (pdus[i].req_len != len)
+			continue;
+
+		if (memcmp(pdus[i].req, data, len))
+			continue;
+
+		util_hexdump('<', pdus[i].rsp, pdus[i].rsp_len, print_data,
+									NULL);
+
+		bthost_send_cid(bthost, cid_data->handle, cid_data->cid,
+						pdus[i].rsp, pdus[i].rsp_len);
+	}
+}
+
+static void a2dp_connect_request_cb(uint16_t handle, uint16_t cid,
+							void *user_data)
+{
+	struct test_data *data = tester_get_data();
+	struct bthost *bthost = hciemu_client_get_host(data->hciemu);
+
+	if (cid_data.handle)
+		return;
+
+	cid_data.handle = handle;
+	cid_data.cid = cid;
+
+	bthost_add_cid_hook(bthost, handle, cid, a2dp_cid_hook_cb, &cid_data);
+}
+
+static struct emu_set_l2cap_data l2cap_setup_data = {
+	.psm = 25,
+	.func = a2dp_connect_request_cb,
+	.user_data = NULL,
+};
+
+static void a2dp_connect_action(void)
+{
+	struct test_data *data = tester_get_data();
+	const uint8_t *addr = hciemu_get_client_bdaddr(data->hciemu);
+	struct step *step = g_new0(struct step, 1);
+	bt_bdaddr_t bdaddr;
+
+	bdaddr2android((const bdaddr_t *) addr, &bdaddr);
+
+	step->action_status = data->if_a2dp->connect(&bdaddr);
+
+	schedule_action_verification(step);
+}
+
 static struct test_case test_cases[] = {
 	TEST_CASE_BREDRLE("A2DP Init",
 		ACTION_SUCCESS(dummy_action, NULL),
 	),
+	TEST_CASE_BREDRLE("A2DP Connect - Success",
+		ACTION_SUCCESS(bluetooth_enable_action, NULL),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+		ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+		ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+		ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
+		ACTION_SUCCESS(a2dp_connect_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTING),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTED),
+		ACTION_SUCCESS(bluetooth_disable_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_DISCONNECTED),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+	),
 };
 
 struct queue *get_a2dp_tests(void)
android/tester-main.c +12 -0
index 6a250a3..51820cf 100644
@@ -1085,8 +1085,20 @@ static bthl_callbacks_t bthl_callbacks = {
 	.channel_state_cb = hdp_channel_state_cb,
 };
 
+static void a2dp_connection_state_cb(btav_connection_state_t state,
+							bt_bdaddr_t *bd_addr)
+{
+	struct step *step = g_new0(struct step, 1);
+
+	step->callback = CB_A2DP_CONN_STATE;
+	step->callback_result.state = state;
+
+	schedule_callback_call(step);
+}
+
 static btav_callbacks_t bta2dp_callbacks = {
 	.size = sizeof(bta2dp_callbacks),
+	.connection_state_cb = a2dp_connection_state_cb,
 };
 
 static const btgatt_client_callbacks_t btgatt_client_callbacks = {
android/tester-main.h +8 -0
index 2cefe5c..32f173b 100644
@@ -180,6 +180,11 @@
 		.callback_result.channel_state = cb_state, \
 	}
 
+#define CALLBACK_AV_CONN_STATE(cb, cb_state) { \
+		.callback = cb, \
+		.callback_result.state = cb_state, \
+	}
+
 #define CALLBACK_DEVICE_PROPS(props, prop_cnt) \
 	CALLBACK_PROPS(CB_BT_REMOTE_DEVICE_PROPERTIES, props, prop_cnt)
 
@@ -243,6 +248,9 @@ typedef enum {
 	CB_HDP_APP_REG_STATE,
 	CB_HDP_CHANNEL_STATE,
 
+	/* A2DP cb */
+	CB_A2DP_CONN_STATE,
+
 	/* Gatt client */
 	CB_GATTC_REGISTER_CLIENT,
 	CB_GATTC_SCAN_RESULT,
Signature · 1 line
1.9.3
author maintainer
#4 lore raw

PATCH v2 5/7 android/tester: Add A2DP Disconnect - Success test case

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/tester-a2dp.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)
android/tester-a2dp.c +39 -0
index a86dcec..ecb0740 100644
@@ -43,6 +43,8 @@ static const uint8_t req_cfg[] = { 0x20, 0x03, 0x04, 0x04, 0x01, 0x00, 0x07,
 static const uint8_t rsp_cfg[] = { 0x22, 0x03 };
 static const uint8_t req_open[] = { 0x30, 0x06, 0x04 };
 static const uint8_t rsp_open[] = { 0x32, 0x06 };
+static const uint8_t req_close[] = { 0x40, 0x08, 0x04 };
+static const uint8_t rsp_close[] = { 0x42, 0x08 };
 
 const struct pdu {
 	const uint8_t *req;
@@ -54,6 +56,7 @@ const struct pdu {
 	{ req_get, sizeof(req_get), rsp_get, sizeof(rsp_get) },
 	{ req_cfg, sizeof(req_cfg), rsp_cfg, sizeof(rsp_cfg) },
 	{ req_open, sizeof(req_open), rsp_open, sizeof(rsp_open) },
+	{ req_close, sizeof(req_close), rsp_close, sizeof(rsp_close) },
 	{ },
 };
 
@@ -114,6 +117,9 @@ static void a2dp_connect_action(void)
 	struct step *step = g_new0(struct step, 1);
 	bt_bdaddr_t bdaddr;
 
+	cid_data.handle = 0;
+	cid_data.cid = 0;
+
 	bdaddr2android((const bdaddr_t *) addr, &bdaddr);
 
 	step->action_status = data->if_a2dp->connect(&bdaddr);
@@ -121,6 +127,20 @@ static void a2dp_connect_action(void)
 	schedule_action_verification(step);
 }
 
+static void a2dp_disconnect_action(void)
+{
+	struct test_data *data = tester_get_data();
+	const uint8_t *addr = hciemu_get_client_bdaddr(data->hciemu);
+	struct step *step = g_new0(struct step, 1);
+	bt_bdaddr_t bdaddr;
+
+	bdaddr2android((const bdaddr_t *) addr, &bdaddr);
+
+	step->action_status = data->if_a2dp->disconnect(&bdaddr);
+
+	schedule_action_verification(step);
+}
+
 static struct test_case test_cases[] = {
 	TEST_CASE_BREDRLE("A2DP Init",
 		ACTION_SUCCESS(dummy_action, NULL),
@@ -141,6 +161,25 @@ static struct test_case test_cases[] = {
 					BTAV_CONNECTION_STATE_DISCONNECTED),
 		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
 	),
+	TEST_CASE_BREDRLE("A2DP Disconnect - Success",
+		ACTION_SUCCESS(bluetooth_enable_action, NULL),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+		ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+		ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+		ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
+		ACTION_SUCCESS(a2dp_connect_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTING),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTED),
+		ACTION_SUCCESS(a2dp_disconnect_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_DISCONNECTING),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_DISCONNECTED),
+		ACTION_SUCCESS(bluetooth_disable_action, NULL),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+	),
 };
 
 struct queue *get_a2dp_tests(void)
Signature · 1 line
1.9.3
author maintainer
#5 lore raw

PATCH v2 6/7 android/tester: Add A2DP Resume - Success test case

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/tester-a2dp.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 android/tester-main.c | 16 ++++++++++++++++
 android/tester-main.h |  7 +++++++
 3 files changed, 69 insertions(+)
android/tester-a2dp.c +46 -0
index ecb0740..6757d75 100644
@@ -45,6 +45,8 @@ static const uint8_t req_open[] = { 0x30, 0x06, 0x04 };
 static const uint8_t rsp_open[] = { 0x32, 0x06 };
 static const uint8_t req_close[] = { 0x40, 0x08, 0x04 };
 static const uint8_t rsp_close[] = { 0x42, 0x08 };
+static const uint8_t req_start[] = { 0x40, 0x07, 0x04 };
+static const uint8_t rsp_start[] = { 0x42, 0x07 };
 
 const struct pdu {
 	const uint8_t *req;
@@ -57,6 +59,7 @@ const struct pdu {
 	{ req_cfg, sizeof(req_cfg), rsp_cfg, sizeof(rsp_cfg) },
 	{ req_open, sizeof(req_open), rsp_open, sizeof(rsp_open) },
 	{ req_close, sizeof(req_close), rsp_close, sizeof(rsp_close) },
+	{ req_start, sizeof(req_start), rsp_start, sizeof(rsp_start) },
 	{ },
 };
 
@@ -141,6 +144,30 @@ static void a2dp_disconnect_action(void)
 	schedule_action_verification(step);
 }
 
+static void audio_resume_action(void)
+{
+	struct test_data *data = tester_get_data();
+	struct step *step = g_new0(struct step, 1);
+	int err;
+
+	err = data->audio->open_output_stream(data->audio,
+						0,
+						AUDIO_DEVICE_OUT_ALL_A2DP,
+						AUDIO_OUTPUT_FLAG_NONE,
+						NULL,
+						&data->if_stream);
+	if (err < 0) {
+		step->action_status = BT_STATUS_FAIL;
+		goto done;
+	}
+
+	/* Write something to force resume */
+	data->if_stream->write(data->if_stream, &err, sizeof(err));
+
+done:
+	schedule_action_verification(step);
+}
+
 static struct test_case test_cases[] = {
 	TEST_CASE_BREDRLE("A2DP Init",
 		ACTION_SUCCESS(dummy_action, NULL),
@@ -180,6 +207,25 @@ static struct test_case test_cases[] = {
 		ACTION_SUCCESS(bluetooth_disable_action, NULL),
 		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
 	),
+	TEST_CASE_BREDRLE("A2DP Resume - Success",
+		ACTION_SUCCESS(bluetooth_enable_action, NULL),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+		ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+		ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+		ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
+		ACTION_SUCCESS(a2dp_connect_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTING),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTED),
+		ACTION_SUCCESS(audio_resume_action, NULL),
+		CALLBACK_AV_AUDIO_STATE(CB_A2DP_AUDIO_STATE,
+					BTAV_AUDIO_STATE_STARTED),
+		ACTION_SUCCESS(bluetooth_disable_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_DISCONNECTED),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+	),
 };
 
 struct queue *get_a2dp_tests(void)
android/tester-main.c +16 -0
index 51820cf..5f41ff1 100644
@@ -1096,9 +1096,20 @@ static void a2dp_connection_state_cb(btav_connection_state_t state,
 	schedule_callback_call(step);
 }
 
+static void a2dp_audio_state_cb(btav_audio_state_t state, bt_bdaddr_t *bd_addr)
+{
+	struct step *step = g_new0(struct step, 1);
+
+	step->callback = CB_A2DP_AUDIO_STATE;
+	step->callback_result.state = state;
+
+	schedule_callback_call(step);
+}
+
 static btav_callbacks_t bta2dp_callbacks = {
 	.size = sizeof(bta2dp_callbacks),
 	.connection_state_cb = a2dp_connection_state_cb,
+	.audio_state_cb = a2dp_audio_state_cb,
 };
 
 static const btgatt_client_callbacks_t btgatt_client_callbacks = {
@@ -1475,6 +1486,11 @@ static void teardown(const void *test_data)
 		data->if_hdp = NULL;
 	}
 
+	if (data->if_stream) {
+		data->audio->close_output_stream(data->audio, data->if_stream);
+		data->if_stream = NULL;
+	}
+
 	if (data->if_a2dp) {
 		data->if_a2dp->cleanup();
 		data->if_a2dp = NULL;
android/tester-main.h +7 -0
index 32f173b..ad87878 100644
@@ -185,6 +185,11 @@
 		.callback_result.state = cb_state, \
 	}
 
+#define CALLBACK_AV_AUDIO_STATE(cb, cb_state) { \
+		.callback = cb, \
+		.callback_result.state = cb_state, \
+	}
+
 #define CALLBACK_DEVICE_PROPS(props, prop_cnt) \
 	CALLBACK_PROPS(CB_BT_REMOTE_DEVICE_PROPERTIES, props, prop_cnt)
 
@@ -250,6 +255,7 @@ typedef enum {
 
 	/* A2DP cb */
 	CB_A2DP_CONN_STATE,
+	CB_A2DP_AUDIO_STATE,
 
 	/* Gatt client */
 	CB_GATTC_REGISTER_CLIENT,
@@ -300,6 +306,7 @@ struct test_data {
 	const btpan_interface_t *if_pan;
 	const bthl_interface_t *if_hdp;
 	const btav_interface_t *if_a2dp;
+	struct audio_stream_out *if_stream;
 	const btgatt_interface_t *if_gatt;
 
 	const void *test_data;
Signature · 1 line
1.9.3
author maintainer
#6 lore raw

PATCH v2 7/7 android/tester: Add A2DP Suspend - Success test case

In reply to Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

---
 android/tester-a2dp.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)
android/tester-a2dp.c +35 -0
index 6757d75..3d006bc 100644
@@ -47,6 +47,8 @@ static const uint8_t req_close[] = { 0x40, 0x08, 0x04 };
 static const uint8_t rsp_close[] = { 0x42, 0x08 };
 static const uint8_t req_start[] = { 0x40, 0x07, 0x04 };
 static const uint8_t rsp_start[] = { 0x42, 0x07 };
+static const uint8_t req_suspend[] = { 0x50, 0x09, 0x04 };
+static const uint8_t rsp_suspend[] = { 0x52, 0x09 };
 
 const struct pdu {
 	const uint8_t *req;
@@ -60,6 +62,7 @@ const struct pdu {
 	{ req_open, sizeof(req_open), rsp_open, sizeof(rsp_open) },
 	{ req_close, sizeof(req_close), rsp_close, sizeof(rsp_close) },
 	{ req_start, sizeof(req_start), rsp_start, sizeof(rsp_start) },
+	{ req_suspend, sizeof(req_suspend), rsp_suspend, sizeof(rsp_start) },
 	{ },
 };
 
@@ -168,6 +171,16 @@ done:
 	schedule_action_verification(step);
 }
 
+static void audio_suspend_action(void)
+{
+	struct test_data *data = tester_get_data();
+	struct step *step = g_new0(struct step, 1);
+
+	data->if_stream->common.standby(&data->if_stream->common);
+
+	schedule_action_verification(step);
+}
+
 static struct test_case test_cases[] = {
 	TEST_CASE_BREDRLE("A2DP Init",
 		ACTION_SUCCESS(dummy_action, NULL),
@@ -226,6 +239,28 @@ static struct test_case test_cases[] = {
 					BTAV_CONNECTION_STATE_DISCONNECTED),
 		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
 	),
+	TEST_CASE_BREDRLE("A2DP Suspend - Success",
+		ACTION_SUCCESS(bluetooth_enable_action, NULL),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
+		ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
+		ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
+		ACTION_SUCCESS(emu_add_l2cap_server_action, &l2cap_setup_data),
+		ACTION_SUCCESS(a2dp_connect_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTING),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_CONNECTED),
+		ACTION_SUCCESS(audio_resume_action, NULL),
+		CALLBACK_AV_AUDIO_STATE(CB_A2DP_AUDIO_STATE,
+					BTAV_AUDIO_STATE_STARTED),
+		ACTION_SUCCESS(audio_suspend_action, NULL),
+		CALLBACK_AV_AUDIO_STATE(CB_A2DP_AUDIO_STATE,
+					BTAV_AUDIO_STATE_STOPPED),
+		ACTION_SUCCESS(bluetooth_disable_action, NULL),
+		CALLBACK_AV_CONN_STATE(CB_A2DP_CONN_STATE,
+					BTAV_CONNECTION_STATE_DISCONNECTED),
+		CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
+	),
 };
 
 struct queue *get_a2dp_tests(void)
Signature · 1 line
1.9.3
author maintainer
#7 lore raw
In reply to Luiz Augusto von Dentz

Hi,

Quoted 26 lines · Luiz Augusto von Dentz

From: Luiz Augusto von Dentz <[email protected]>

This can cause the followin error:
audio.a2dp.default.so: undefined symbol: queue_foreach
---
v2: Rebase properly

 android/Makefile.am | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
android/Makefile.am +3 -2
index ac3a766..263a506 100644
@@ -198,7 +198,9 @@ android_audio_a2dp_default_la_SOURCES = android/audio-msg.h \
                                        android/hardware/audio.h \
                                        android/hardware/audio_effect.h \
                                        android/hardware/hardware.h \
-                                       android/system/audio.h
+                                       android/system/audio.h \
+                                       src/shared/queue.h \
+                                       src/shared/queue.c
 
 android_audio_sco_default_la_SOURCES = android/hal-log.h \
                                        android/sco-msg.h \
--
Quoted 2 lines

1.9.3

Pushed.

Signature · 1 line
Luiz Augusto von Dentz