diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2019-04-01 23:22:29 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2019-04-01 23:22:29 +0000 |
commit | 20af391b358ca244a539069f0655aeb4426920ef (patch) | |
tree | b63336895e8e2e199d851a394e55a8c19de3574e | |
parent | 6ac6f94835ce708d9835445ad24b898de931e1b2 (diff) | |
parent | 51e6bc4414b9ee4ff9db904b4117ca4df57b5f70 (diff) | |
download | android_hardware_qcom_audio-20af391b358ca244a539069f0655aeb4426920ef.tar.gz android_hardware_qcom_audio-20af391b358ca244a539069f0655aeb4426920ef.tar.bz2 android_hardware_qcom_audio-20af391b358ca244a539069f0655aeb4426920ef.zip |
Merge "qcom/audio/hal: add offset to MMAP output time"
-rw-r--r-- | hal/audio_hw.c | 17 | ||||
-rw-r--r-- | hal/audio_hw.h | 1 |
2 files changed, 17 insertions, 1 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c index f8bf0c98..2807bcc9 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -3789,6 +3789,17 @@ static void adjust_mmap_period_count(struct pcm_config *config, int32_t min_size ALOGV("%s requested config.period_count = %d", __func__, config->period_count); } +// Read offset for the positional timestamp from a persistent vendor property. +// This is to workaround apparent inaccuracies in the timing information that +// is used by the AAudio timing model. The inaccuracies can cause glitches. +static int64_t get_mmap_out_time_offset() { + const int32_t kDefaultOffsetMicros = 0; + int32_t mmap_time_offset_micros = property_get_int32( + "persist.audio.out_mmap_delay_micros", kDefaultOffsetMicros); + ALOGI("mmap_time_offset_micros = %d for output", mmap_time_offset_micros); + return mmap_time_offset_micros * (int64_t)1000; +} + static int out_create_mmap_buffer(const struct audio_stream_out *stream, int32_t min_size_frames, struct audio_mmap_buffer_info *info) @@ -3866,6 +3877,8 @@ static int out_create_mmap_buffer(const struct audio_stream_out *stream, goto exit; } + out->mmap_time_offset_nanos = get_mmap_out_time_offset(); + out->standby = false; ret = 0; @@ -3909,7 +3922,9 @@ static int out_get_mmap_position(const struct audio_stream_out *stream, ALOGE("%s: %s", __func__, pcm_get_error(out->pcm)); goto exit; } - position->time_nanoseconds = audio_utils_ns_from_timespec(&ts); + position->time_nanoseconds = audio_utils_ns_from_timespec(&ts) + + out->mmap_time_offset_nanos; + exit: pthread_mutex_unlock(&out->lock); return ret; diff --git a/hal/audio_hw.h b/hal/audio_hw.h index 7bca0704..09926501 100644 --- a/hal/audio_hw.h +++ b/hal/audio_hw.h @@ -232,6 +232,7 @@ struct stream_out { uint32_t supported_sample_rates[MAX_SUPPORTED_SAMPLE_RATES + 1]; bool muted; uint64_t written; /* total frames written, not cleared when entering standby */ + int64_t mmap_time_offset_nanos; /* fudge factor to correct inaccuracies in DSP */ audio_io_handle_t handle; int non_blocking; |