summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuca Stefani <luca.stefani.ge1@gmail.com>2019-07-13 18:58:07 +0200
committerLuca Stefani <luca.stefani.ge1@gmail.com>2019-07-13 18:58:07 +0200
commit768ef731624a973eece61d112d5eec8ceb77ed11 (patch)
treeff4905cd30fd20b9caba18d8b7d8f514744844ed
parent4a0bd95db0de8753f64b0df9577a11bae315b548 (diff)
parentab7d2ba3b5824e2efa5c970f7a5e0a578c9bbb9c (diff)
downloadhardware_qcom_audio-lineage-16.0.tar.gz
hardware_qcom_audio-lineage-16.0.tar.bz2
hardware_qcom_audio-lineage-16.0.zip
Merge remote-tracking branch 'aosp/pie-gsi' into lineage-16.0-pie-gsilineage-16.0
* aosp/pie-gsi: qcom/audio/hal: add offset to MMAP output time qcom/audio/hal: add offset to MMAP input time qcom/audio/hal: add offset to MMAP input time Change-Id: Id2f0b1ada3d8d9bb00f317c6e63f355958cf866a
-rw-r--r--hal/audio_hw.c34
-rw-r--r--hal/audio_hw.h2
2 files changed, 34 insertions, 2 deletions
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index f315b5e5..345cfa6d 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -3360,6 +3360,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)
@@ -3437,6 +3448,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;
@@ -3480,7 +3493,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;
@@ -3994,6 +4009,17 @@ static int in_start(const struct audio_stream_in* stream)
return ret;
}
+// 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 in_get_mmap_time_offset() {
+ const int32_t kDefaultOffsetMicros = 0;
+ int32_t mmap_time_offset_micros = property_get_int32(
+ "persist.audio.in_mmap_delay_micros", kDefaultOffsetMicros);
+ ALOGI("mmap_time_offset_micros = %d for input", mmap_time_offset_micros);
+ return mmap_time_offset_micros * (int64_t)1000;
+}
+
static int in_create_mmap_buffer(const struct audio_stream_in *stream,
int32_t min_size_frames,
struct audio_mmap_buffer_info *info)
@@ -4074,6 +4100,8 @@ static int in_create_mmap_buffer(const struct audio_stream_in *stream,
goto exit;
}
+ in->mmap_time_offset_nanos = in_get_mmap_time_offset();
+
in->standby = false;
ret = 0;
@@ -4116,7 +4144,9 @@ static int in_get_mmap_position(const struct audio_stream_in *stream,
ALOGE("%s: %s", __func__, pcm_get_error(in->pcm));
goto exit;
}
- position->time_nanoseconds = audio_utils_ns_from_timespec(&ts);
+ position->time_nanoseconds = audio_utils_ns_from_timespec(&ts)
+ + in->mmap_time_offset_nanos;
+
exit:
pthread_mutex_unlock(&in->lock);
return ret;
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index 0b3b0281..a97b47cb 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -230,6 +230,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;
@@ -274,6 +275,7 @@ struct stream_in {
bool enable_ns;
int64_t frames_read; /* total frames read, not cleared when entering standby */
int64_t frames_muted; /* total frames muted, not cleared when entering standby */
+ int64_t mmap_time_offset_nanos; /* fudge factor to correct inaccuracies in DSP */
audio_io_handle_t capture_handle;
audio_input_flags_t flags;