diff options
author | Andy Hung <hunga@google.com> | 2015-05-06 09:58:05 -0700 |
---|---|---|
committer | Andy Hung <hunga@google.com> | 2015-05-07 12:20:50 -0700 |
commit | b290670d9ceb730556909afb4a5a28076b4e3771 (patch) | |
tree | 2b7ef4e486d1e71506d8ee2e9cec5c2371ca1314 /alsa_utils | |
parent | dca2ec0a335a6be68ce74baa3aca4458d48c78bb (diff) | |
download | android_system_media-b290670d9ceb730556909afb4a5a28076b4e3771.tar.gz android_system_media-b290670d9ceb730556909afb4a5a28076b4e3771.tar.bz2 android_system_media-b290670d9ceb730556909afb4a5a28076b4e3771.zip |
Allow up to 192kHz sampling rate for usb
Change-Id: I0f835f2589fbbe640fab3a7622467d2218b5b877
Diffstat (limited to 'alsa_utils')
-rw-r--r-- | alsa_utils/alsa_device_profile.c | 38 | ||||
-rw-r--r-- | alsa_utils/include/alsa_device_profile.h | 4 |
2 files changed, 21 insertions, 21 deletions
diff --git a/alsa_utils/alsa_device_profile.c b/alsa_utils/alsa_device_profile.c index 9efbe0bb..9e5b8821 100644 --- a/alsa_utils/alsa_device_profile.c +++ b/alsa_utils/alsa_device_profile.c @@ -54,27 +54,26 @@ static const unsigned const format_byte_size_map[] = { extern int8_t const pcm_format_value_map[50]; -/* sort these highest -> lowest (to default to best quality) */ +/* Sort these in terms of preference (best first). + 192 kHz is not first because it requires significant resources for possibly worse + quality and driver instability (depends on device). + The order here determines the default sample rate for the device. + AudioPolicyManager may not respect this ordering when picking sample rates. + Update MAX_PROFILE_SAMPLE_RATES after changing the array size. + + TODO: remove 32000, 22050, 12000, 11025? Each sample rate check + requires opening the device which may cause pops. */ static const unsigned std_sample_rates[] = - {/*96000,*/ 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000}; + {96000, 88200, 192000, 176400, 48000, 44100, 32000, 24000, 22050, 16000, 12000, 11025, 8000}; static void profile_reset(alsa_device_profile* profile) { profile->card = profile->device = -1; - /* Fill the attribute arrays with invalid values */ - size_t index; - for (index = 0; index < ARRAY_SIZE(profile->formats); index++) { - profile->formats[index] = PCM_FORMAT_INVALID; - } - - for (index = 0; index < ARRAY_SIZE(profile->sample_rates); index++) { - profile->sample_rates[index] = 0; - } - - for (index = 0; index < ARRAY_SIZE(profile->channel_counts); index++) { - profile->channel_counts[index] = 0; - } + /* terminate the attribute arrays with invalid values */ + profile->formats[0] = PCM_FORMAT_INVALID; + profile->sample_rates[0] = 0; + profile->channel_counts[0] = 0; profile->min_period_size = profile->max_period_size = 0; profile->min_channel_count = profile->max_channel_count = DEFAULT_CHANNEL_COUNT; @@ -238,7 +237,7 @@ static unsigned profile_enum_sample_rates(alsa_device_profile* profile, unsigned profile->sample_rates[num_entries++] = std_sample_rates[index]; } } - + profile->sample_rates[num_entries] = 0; /* terminate */ return num_entries; /* return # of supported rates */ } @@ -265,7 +264,7 @@ static unsigned profile_enum_sample_formats(alsa_device_profile* profile, struct profile->formats[num_written++] = format; if (num_written == ARRAY_SIZE(profile->formats) - 1) { /* leave at least one PCM_FORMAT_INVALID at the end */ - return num_written; + goto end; } } } @@ -273,7 +272,8 @@ static unsigned profile_enum_sample_formats(alsa_device_profile* profile, struct table_index++; } } - +end: + profile->formats[num_written] = PCM_FORMAT_INVALID; return num_written; } @@ -295,7 +295,7 @@ static unsigned profile_enum_channel_counts(alsa_device_profile* profile, unsign profile->channel_counts[num_counts++] = std_channel_counts[index]; } } - + profile->channel_counts[num_counts] = 0; return num_counts; /* return # of supported counts */ } diff --git a/alsa_utils/include/alsa_device_profile.h b/alsa_utils/include/alsa_device_profile.h index b793add8..4de8998e 100644 --- a/alsa_utils/include/alsa_device_profile.h +++ b/alsa_utils/include/alsa_device_profile.h @@ -24,8 +24,8 @@ #define MAX_PROFILE_FORMATS 6 /* We long support the 5 standard formats defined * in asound.h, so we just need this to be 1 more * than that */ -#define MAX_PROFILE_SAMPLE_RATES 10 /* this number needs to be 1 more than the number of - * standard formats in std_sample_rates[] +#define MAX_PROFILE_SAMPLE_RATES 14 /* this number needs to be 1 more than the number of + * sample rates in std_sample_rates[] * (in alsa_device_profile.c) */ #define MAX_PROFILE_CHANNEL_COUNTS 5 /* this number need to be 1 more than the number of * standard channel formats in std_channel_counts[] |