From a768c306b2391b8b573f047de3416c693fa50e62 Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Mon, 28 Jul 2014 11:33:43 -0700 Subject: [PATCH] audio: add audio device address helper function Add helper function to derive set_parameter command string from device type and address. 14815883 Change-Id: Icf47218f1809f567ef93bdd99d6308475886b298 --- include/system/audio.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/system/audio.h b/include/system/audio.h index 13c8ae5be..a2873890f 100644 --- a/include/system/audio.h +++ b/include/system/audio.h @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -1325,6 +1326,23 @@ static inline size_t audio_bytes_per_sample(audio_format_t format) return size; } +/* converts device address to string sent to audio HAL via set_parameters */ +static char *audio_device_address_to_parameter(audio_devices_t device, const char *address) +{ + const size_t kSize = AUDIO_DEVICE_MAX_ADDRESS_LEN + sizeof("a2dp_sink_address="); + char param[kSize]; + + if (device & AUDIO_DEVICE_OUT_ALL_A2DP) + snprintf(param, kSize, "%s=%s", "a2dp_sink_address", address); + else if (device & AUDIO_DEVICE_OUT_REMOTE_SUBMIX) + snprintf(param, kSize, "%s=%s", "mix", address); + else + snprintf(param, kSize, "%s", address); + + return strdup(param); +} + + __END_DECLS #endif // ANDROID_AUDIO_CORE_H