summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2022-05-06 09:14:27 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-05-06 09:14:27 +0000
commit0c76fbc3adb94f9d174963b2476e232f27b3cba0 (patch)
tree9c246e891cec42ac1c2a67629975937fbeef777a
parent165de6c6512a9ca95923971c7284c8aabb2ed79f (diff)
parenta1a87002a23c8ef272013a54c1496368e2d76ab3 (diff)
downloadmedia-0c76fbc3adb94f9d174963b2476e232f27b3cba0.tar.gz
Merge "audio: utility and macros for LE audio broadcast" into tm-dev am: 575e3bb555 am: a1a87002a2
Original change: https://googleplex-android-review.googlesource.com/c/platform/system/media/+/17183474 Change-Id: I3863dace73d2c480682e303bd7bca0ceedebc0ea Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--audio/include/system/audio-base-utils.h10
-rw-r--r--audio/include/system/audio.h7
-rw-r--r--tests/systemaudio_tests.cpp3
3 files changed, 20 insertions, 0 deletions
diff --git a/audio/include/system/audio-base-utils.h b/audio/include/system/audio-base-utils.h
index 5f094c88..525a3837 100644
--- a/audio/include/system/audio-base-utils.h
+++ b/audio/include/system/audio-base-utils.h
@@ -229,6 +229,11 @@ static CONST_ARRAY audio_devices_t AUDIO_DEVICE_OUT_ALL_BLE_ARRAY[] = {
AUDIO_DEVICE_OUT_BLE_BROADCAST, // 0x20000002u
};
+static CONST_ARRAY audio_devices_t AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY[] = {
+ AUDIO_DEVICE_OUT_BLE_HEADSET, // 0x20000000u
+ AUDIO_DEVICE_OUT_BLE_SPEAKER, // 0x20000001u
+};
+
// inline constexpr
static CONST_ARRAY audio_devices_t AUDIO_DEVICE_IN_ALL_ARRAY[] = {
AUDIO_DEVICE_IN_COMMUNICATION, // 0x80000001u
@@ -312,6 +317,8 @@ static const uint32_t AUDIO_DEVICE_OUT_DIGITAL_CNT = AUDIO_ARRAY_SIZE(
AUDIO_DEVICE_OUT_ALL_DIGITAL_ARRAY);
static const uint32_t AUDIO_DEVICE_OUT_BLE_CNT = AUDIO_ARRAY_SIZE(
AUDIO_DEVICE_OUT_ALL_BLE_ARRAY);
+static const uint32_t AUDIO_DEVICE_OUT_BLE_UNICAST_CNT = AUDIO_ARRAY_SIZE(
+ AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY);
static const uint32_t AUDIO_DEVICE_IN_CNT = AUDIO_ARRAY_SIZE(AUDIO_DEVICE_IN_ALL_ARRAY);
static const uint32_t AUDIO_DEVICE_IN_SCO_CNT = AUDIO_ARRAY_SIZE(AUDIO_DEVICE_IN_ALL_SCO_ARRAY);
@@ -357,6 +364,8 @@ static_assert(isSorted(AUDIO_DEVICE_OUT_ALL_DIGITAL_ARRAY),
"AUDIO_DEVICE_OUT_ALL_DIGITAL_ARRAY must be sorted");
static_assert(isSorted(AUDIO_DEVICE_OUT_ALL_BLE_ARRAY),
"AUDIO_DEVICE_OUT_ALL_BLE_ARRAY must be sorted");
+static_assert(isSorted(AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY),
+ "AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY must be sorted");
static_assert(isSorted(AUDIO_DEVICE_IN_ALL_ARRAY),
"AUDIO_DEVICE_IN_ALL_ARRAY must be sorted");
static_assert(isSorted(AUDIO_DEVICE_IN_ALL_SCO_ARRAY),
@@ -374,6 +383,7 @@ static_assert(AUDIO_DEVICE_OUT_SCO_CNT == std::size(AUDIO_DEVICE_OUT_ALL_SCO_ARR
static_assert(AUDIO_DEVICE_OUT_USB_CNT == std::size(AUDIO_DEVICE_OUT_ALL_USB_ARRAY));
static_assert(AUDIO_DEVICE_OUT_DIGITAL_CNT == std::size(AUDIO_DEVICE_OUT_ALL_DIGITAL_ARRAY));
static_assert(AUDIO_DEVICE_OUT_BLE_CNT == std::size(AUDIO_DEVICE_OUT_ALL_BLE_ARRAY));
+static_assert(AUDIO_DEVICE_OUT_BLE_UNICAST_CNT == std::size(AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY));
static_assert(AUDIO_DEVICE_IN_CNT == std::size(AUDIO_DEVICE_IN_ALL_ARRAY));
static_assert(AUDIO_DEVICE_IN_SCO_CNT == std::size(AUDIO_DEVICE_IN_ALL_SCO_ARRAY));
static_assert(AUDIO_DEVICE_IN_USB_CNT == std::size(AUDIO_DEVICE_IN_ALL_USB_ARRAY));
diff --git a/audio/include/system/audio.h b/audio/include/system/audio.h
index 25092f6d..2f7fe23e 100644
--- a/audio/include/system/audio.h
+++ b/audio/include/system/audio.h
@@ -1386,6 +1386,13 @@ static inline bool audio_is_ble_out_device(audio_devices_t device)
AUDIO_DEVICE_OUT_ALL_BLE_ARRAY, 0 /*left*/, AUDIO_DEVICE_OUT_BLE_CNT, device);
}
+static inline bool audio_is_ble_unicast_device(audio_devices_t device)
+{
+ return audio_binary_search_device_array(
+ AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY, 0 /*left*/,
+ AUDIO_DEVICE_OUT_BLE_UNICAST_CNT, device);
+}
+
static inline bool audio_is_ble_in_device(audio_devices_t device)
{
return audio_binary_search_device_array(
diff --git a/tests/systemaudio_tests.cpp b/tests/systemaudio_tests.cpp
index 79052f59..985673f8 100644
--- a/tests/systemaudio_tests.cpp
+++ b/tests/systemaudio_tests.cpp
@@ -205,6 +205,9 @@ TEST(SystemAudioTest, AudioDeviceTypeHelperFunction) {
runAudioDeviceTypeHelperFunction(allDeviceTypes, AUDIO_DEVICE_IN_ALL_BLE_ARRAY,
std::size(AUDIO_DEVICE_IN_ALL_BLE_ARRAY), "ble in",
audio_is_ble_in_device);
+ runAudioDeviceTypeHelperFunction(allDeviceTypes, AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY,
+ std::size(AUDIO_DEVICE_OUT_BLE_UNICAST_ARRAY), "ble unicast",
+ audio_is_ble_unicast_device);
}