summaryrefslogtreecommitdiffstats
path: root/alsa_utils
diff options
context:
space:
mode:
authorAndy Hung <hunga@google.com>2015-04-21 13:31:16 -0700
committerAndy Hung <hunga@google.com>2015-05-06 09:09:48 -0700
commit3f822c559a5515caaa48459d0d5772ad1779bdb8 (patch)
treeb81bee7b1db1d1dac32e1b5854562a2847458c99 /alsa_utils
parentddda2bb917a1eb725c85d8c2b61bff2abf568a95 (diff)
downloadandroid_system_media-3f822c559a5515caaa48459d0d5772ad1779bdb8.tar.gz
android_system_media-3f822c559a5515caaa48459d0d5772ad1779bdb8.tar.bz2
android_system_media-3f822c559a5515caaa48459d0d5772ad1779bdb8.zip
Alsa profile changes for multichannel input
Change-Id: I6f92a601524fc19b0acccd72d426f0c033e1ec26
Diffstat (limited to 'alsa_utils')
-rw-r--r--alsa_utils/alsa_device_profile.c48
1 files changed, 34 insertions, 14 deletions
diff --git a/alsa_utils/alsa_device_profile.c b/alsa_utils/alsa_device_profile.c
index 84886130..7f6071c7 100644
--- a/alsa_utils/alsa_device_profile.c
+++ b/alsa_utils/alsa_device_profile.c
@@ -56,7 +56,7 @@ extern int8_t const pcm_format_value_map[50];
/* sort these highest -> lowest (to default to best quality) */
static const unsigned std_sample_rates[] =
- {48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
+ {/*96000,*/ 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000};
static void profile_reset(alsa_device_profile* profile)
{
@@ -423,11 +423,6 @@ char * profile_get_sample_rate_strs(alsa_device_profile* profile)
char * profile_get_format_strs(alsa_device_profile* profile)
{
- /* TODO remove this hack when we have support for input in non PCM16 formats */
- if (profile->direction == PCM_IN) {
- return strdup("AUDIO_FORMAT_PCM_16_BIT");
- }
-
/* if we assume that format strings are about 24 characters (AUDIO_FORMAT_PCM_16_BIT is 23),
* plus ~1 for a delimiter "|" this buffer has room for about 10 format strings which seems
* like way too much, but it's a stack variable so only temporary.
@@ -479,6 +474,18 @@ char * profile_get_channel_count_strs(alsa_device_profile* profile)
/* channel counts greater than this not considered */
};
+ static const char * const index_chans_strs[] = {
+ /* 0 */"AUDIO_CHANNEL_NONE", /* will never be taken as this is a terminator */
+ /* 1 */"AUDIO_CHANNEL_INDEX_MASK_1",
+ /* 2 */"AUDIO_CHANNEL_INDEX_MASK_2",
+ /* 3 */"AUDIO_CHANNEL_INDEX_MASK_3",
+ /* 4 */"AUDIO_CHANNEL_INDEX_MASK_4",
+ /* 5 */"AUDIO_CHANNEL_INDEX_MASK_5",
+ /* 6 */"AUDIO_CHANNEL_INDEX_MASK_6",
+ /* 7 */"AUDIO_CHANNEL_INDEX_MASK_7",
+ /* 8 */"AUDIO_CHANNEL_INDEX_MASK_8",
+ };
+
const bool isOutProfile = profile->direction == PCM_OUT;
const char * const * const chans_strs = isOutProfile ? out_chans_strs : in_chans_strs;
@@ -486,11 +493,10 @@ char * profile_get_channel_count_strs(alsa_device_profile* profile)
isOutProfile ? ARRAY_SIZE(out_chans_strs) : ARRAY_SIZE(in_chans_strs);
/*
- * If we assume each channel string is 24 chars ("AUDIO_CHANNEL_OUT_7POINT1" is 25) + 1 for,
- * the "|" delimiter, then we have room for about 10 strings (which is more than we
- * currently support).
+ * If we assume each channel string is 26 chars ("AUDIO_CHANNEL_INDEX_MASK_8" is 26) + 1 for,
+ * the "|" delimiter, then we allocate room for 16 strings.
*/
- char buffer[256]; /* caution, may need to be expanded */
+ char buffer[27 * 16 + 1]; /* caution, may need to be expanded */
buffer[0] = '\0';
size_t buffSize = ARRAY_SIZE(buffer);
size_t curStrLen = 0;
@@ -506,11 +512,11 @@ char * profile_get_channel_count_strs(alsa_device_profile* profile)
size_t index;
unsigned channel_count;
for (index = 0;
- (channel_count = profile->channel_counts[index]) != 0
- && channel_count < chans_strs_size
- && chans_strs[channel_count] != NULL;
+ (channel_count = profile->channel_counts[index]) != 0;
index++) {
- if (channel_count != 2) {
+ if (channel_count < chans_strs_size
+ && chans_strs[channel_count] != NULL
+ && channel_count != 2 /* stereo already supported */) {
// account for the '|' and the '\0'
if (buffSize - curStrLen < strlen(chans_strs[channel_count]) + 2) {
/* we don't have room for another, so bail at this point rather than
@@ -522,6 +528,20 @@ char * profile_get_channel_count_strs(alsa_device_profile* profile)
strlcat(buffer, "|", buffSize);
curStrLen = strlcat(buffer, chans_strs[channel_count], buffSize);
}
+ // for input allow channel index masks.
+ // TODO: allow for output as well?
+ if (!isOutProfile) {
+ // account for the '|' and the '\0'
+ if (buffSize - curStrLen < strlen(index_chans_strs[channel_count]) + 2) {
+ /* we don't have room for another, so bail at this point rather than
+ * return a malformed rate string
+ */
+ break;
+ }
+
+ strlcat(buffer, "|", buffSize);
+ curStrLen = strlcat(buffer, index_chans_strs[channel_count], buffSize);
+ }
}
return strdup(buffer);