diff options
| author | Glenn Kasten <gkasten@google.com> | 2014-06-12 11:44:48 -0700 |
|---|---|---|
| committer | Glenn Kasten <gkasten@google.com> | 2014-06-12 11:46:51 -0700 |
| commit | ddd5f65fa348fd541391bab42fba1622db312613 (patch) | |
| tree | f633ed82650570c3f0ca18efb087c28bde2e72ec /hal | |
| parent | 8e6e98fc5af6d6f79bc71eb37df470380ae82fad (diff) | |
| parent | 4f99339176510e3a9995fb84797efb6e77de3572 (diff) | |
| download | android_hardware_qcom_audio-ddd5f65fa348fd541391bab42fba1622db312613.tar.gz android_hardware_qcom_audio-ddd5f65fa348fd541391bab42fba1622db312613.tar.bz2 android_hardware_qcom_audio-ddd5f65fa348fd541391bab42fba1622db312613.zip | |
resolved conflicts for merge of 4f993391 to master
Change-Id: I5a1fd2107a613f2dd2c5c59c4c3e3e279f85585b
Diffstat (limited to 'hal')
| -rw-r--r-- | hal/audio_hw.c | 54 | ||||
| -rw-r--r-- | hal/msm8960/platform.h | 4 | ||||
| -rw-r--r-- | hal/msm8974/platform.h | 4 |
3 files changed, 59 insertions, 3 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c index f7f8d289..615c5c15 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -57,6 +57,9 @@ #define COMPRESS_OFFLOAD_PLAYBACK_LATENCY 96 #define COMPRESS_PLAYBACK_VOLUME_MAX 0x2000 +static unsigned int configured_low_latency_capture_period_size = + LOW_LATENCY_CAPTURE_PERIOD_SIZE; + /* This constant enables extended precision handling. * TODO The flag is off until more testing is done. */ @@ -1129,13 +1132,19 @@ static size_t get_input_buffer_size(uint32_t sample_rate, return 0; size = (sample_rate * AUDIO_CAPTURE_PERIOD_DURATION_MSEC) / 1000; + if (sample_rate == LOW_LATENCY_CAPTURE_SAMPLE_RATE) + size = configured_low_latency_capture_period_size; /* ToDo: should use frame_size computed based on the format and channel_count here. */ size *= sizeof(short) * channel_count; - /* make sure the size is multiple of 64 */ - size += 0x3f; - size &= ~0x3f; + /* make sure the size is multiple of 32 bytes + * At 48 kHz mono 16-bit PCM: + * 5.000 ms = 240 frames = 15*16*1*2 = 480, a whole multiple of 32 (15) + * 3.333 ms = 160 frames = 10*16*1*2 = 320, a whole multiple of 32 (10) + */ + size += 0x1f; + size &= ~0x1f; return size; } @@ -2312,6 +2321,10 @@ static int adev_open_input_stream(struct audio_hw_device *dev, /* Update config params with the requested sample rate and channels */ in->usecase = USECASE_AUDIO_RECORD; +#if LOW_LATENCY_CAPTURE_USE_CASE + if (config->sample_rate == LOW_LATENCY_CAPTURE_SAMPLE_RATE) + in->usecase = USECASE_AUDIO_RECORD_LOW_LATENCY; +#endif in->config = pcm_config_audio_capture; in->config.channels = channel_count; in->config.rate = config->sample_rate; @@ -2496,6 +2509,23 @@ static int adev_close(hw_device_t *device) return 0; } +/* This returns 1 if the input parameter looks at all plausible as a low latency period size, + * or 0 otherwise. A return value of 1 doesn't mean the value is guaranteed to work, + * just that it _might_ work. + */ +static int period_size_is_plausible_for_low_latency(int period_size) +{ + switch (period_size) { + case 160: + case 240: + case 320: + case 480: + return 1; + default: + return 0; + } +} + static int adev_open(const hw_module_t *module, const char *name, hw_device_t **device) { @@ -2578,6 +2608,24 @@ static int adev_open(const hw_module_t *module, const char *name, if (k_enable_extended_precision) adev_verify_devices(adev); + char value[PROPERTY_VALUE_MAX]; + int trial; + if (property_get("audio_hal.period_size", value, NULL) > 0) { + trial = atoi(value); + if (period_size_is_plausible_for_low_latency(trial)) { + pcm_config_low_latency.period_size = trial; + pcm_config_low_latency.start_threshold = trial / 4; + pcm_config_low_latency.avail_min = trial / 4; + configured_low_latency_capture_period_size = trial; + } + } + if (property_get("audio_hal.in_period_size", value, NULL) > 0) { + trial = atoi(value); + if (period_size_is_plausible_for_low_latency(trial)) { + configured_low_latency_capture_period_size = trial; + } + } + ALOGV("%s: exit", __func__); return 0; } diff --git a/hal/msm8960/platform.h b/hal/msm8960/platform.h index 391e9119..a2ae80f8 100644 --- a/hal/msm8960/platform.h +++ b/hal/msm8960/platform.h @@ -116,4 +116,8 @@ enum { #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 #define AUDIO_CAPTURE_PERIOD_COUNT 2 +#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 +#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 +#define LOW_LATENCY_CAPTURE_USE_CASE 0 + #endif // QCOM_AUDIO_PLATFORM_H diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h index 18711d83..42bf8e5d 100644 --- a/hal/msm8974/platform.h +++ b/hal/msm8974/platform.h @@ -131,6 +131,10 @@ enum { #define AUDIO_CAPTURE_PERIOD_DURATION_MSEC 20 #define AUDIO_CAPTURE_PERIOD_COUNT 2 +#define LOW_LATENCY_CAPTURE_SAMPLE_RATE 48000 +#define LOW_LATENCY_CAPTURE_PERIOD_SIZE 240 +#define LOW_LATENCY_CAPTURE_USE_CASE 1 + #define DEEP_BUFFER_PCM_DEVICE 0 #define AUDIO_RECORD_PCM_DEVICE 0 #define MULTIMEDIA2_PCM_DEVICE 1 |
