summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2014-07-28 11:33:43 -0700
committerEric Laurent <elaurent@google.com>2014-07-28 19:24:50 +0000
commita768c306b2391b8b573f047de3416c693fa50e62 (patch)
treea2960b8ee0301ab11d10e88b39fc9a3df18d7255 /include
parent0a381a379d00f708a0dfe4da758697128177749a (diff)
downloadsystem_core-a768c306b2391b8b573f047de3416c693fa50e62.zip
system_core-a768c306b2391b8b573f047de3416c693fa50e62.tar.gz
system_core-a768c306b2391b8b573f047de3416c693fa50e62.tar.bz2
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
Diffstat (limited to 'include')
-rw-r--r--include/system/audio.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/include/system/audio.h b/include/system/audio.h
index 13c8ae5..a287389 100644
--- a/include/system/audio.h
+++ b/include/system/audio.h
@@ -20,6 +20,7 @@
#include <stdbool.h>
#include <stdint.h>
+#include <stdio.h>
#include <sys/cdefs.h>
#include <sys/types.h>
@@ -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