hal: Fix AudioRecord and AudioTrack timestamps incorrect
Calculate the timestamps with platfrom and snd device delay.
Add delay for snd device from xml and add platform rendor delay
with snd device delay for capture and playback usecases.
Bug: 137325602
Test: manual test
Change-Id: I2a606018cb1fb6678459e3a407dcb02b7db1b074
Signed-off-by: Robert Lee <lerobert@google.com>
(cherry picked from commit 225f7d47ac137746f99b4a436dfc279dc7be7918)
Signed-off-by: Aniket Kumar Lata <alata@codeaurora.org>
diff --git a/hal/platform_info.c b/hal/platform_info.c
index 5e25533..40b22bc 100644
--- a/hal/platform_info.c
+++ b/hal/platform_info.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -77,6 +77,7 @@
CUSTOM_MTMX_IN_PARAMS,
CUSTOM_MTMX_PARAM_IN_CH_INFO,
MMSECNS,
+ SND_DEV_DELAY,
} section_t;
typedef void (* section_process_fn)(const XML_Char **attr);
@@ -104,6 +105,7 @@
static void process_custom_mtmx_in_params(const XML_Char **attr);
static void process_custom_mtmx_param_in_ch_info(const XML_Char **attr);
static void process_fluence_mmsecns(const XML_Char **attr);
+static void process_snd_device_delay(const XML_Char **attr);
static section_process_fn section_table[] = {
[ROOT] = process_root,
@@ -128,6 +130,7 @@
[CUSTOM_MTMX_IN_PARAMS] = process_custom_mtmx_in_params,
[CUSTOM_MTMX_PARAM_IN_CH_INFO] = process_custom_mtmx_param_in_ch_info,
[MMSECNS] = process_fluence_mmsecns,
+ [SND_DEV_DELAY] = process_snd_device_delay,
};
static section_t section;
@@ -701,6 +704,34 @@
return;
}
+
+static void process_snd_device_delay(const XML_Char **attr)
+{
+ snd_device_t snd_device = SND_DEVICE_NONE;
+
+ if (strcmp(attr[0], "name") != 0) {
+ ALOGE("%s: 'name' not found", __func__);
+ goto done;
+ }
+
+ snd_device = platform_get_snd_device_index((char *)attr[1]);
+ if (snd_device < 0) {
+ ALOGE("%s: Device %s in %s not found, no ACDB ID set!",
+ __func__, (char *)attr[3], PLATFORM_INFO_XML_PATH);
+ goto done;
+ }
+
+ if (strcmp(attr[2], "delay") != 0) {
+ ALOGE("%s: 'delay' not found", __func__);
+ goto done;
+ }
+
+ platform_set_snd_device_delay(snd_device, atoi((char *)attr[3]));
+
+done:
+ return;
+}
+
static void process_config_params(const XML_Char **attr)
{
if (strcmp(attr[0], "key") != 0) {
@@ -1437,6 +1468,9 @@
return;
}
section = CUSTOM_MTMX_PARAM_IN_CH_INFO;
+ } else if (strcmp(tag_name, "snd_device_delay") == 0) {
+ section = SND_DEV_DELAY;
+ } else if (strcmp(tag_name, "device_delay") == 0) {
section_process_fn fn = section_table[section];
fn(attr);
}