From fa377bff1524a0f277863e8ed49423f4c4ace005 Mon Sep 17 00:00:00 2001 From: Deeraj Soman Date: Wed, 6 Feb 2019 12:57:59 +0530 Subject: [PATCH] hal: Add support for FAST FLAG in compress path Add support for FAST FLAG in capture path. Clients may request to open the compress session in perf mode by passing the FAST FLAG. Change-Id: I2b6cc50b0dd45aa6d6d78362392e4ee39dddd967 --- hal/audio_extn/audio_extn.h | 1 + hal/audio_extn/compress_in.c | 5 +++++ hal/audio_extn/utils.c | 9 +++++++++ hal/audio_hw.c | 7 +++++++ 4 files changed, 22 insertions(+) diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h index 97b7688e..a172ce42 100644 --- a/hal/audio_extn/audio_extn.h +++ b/hal/audio_extn/audio_extn.h @@ -1096,6 +1096,7 @@ int audio_extn_utils_compress_get_dsp_presentation_pos(struct stream_out *out, int audio_extn_utils_pcm_get_dsp_presentation_pos(struct stream_out *out, uint64_t *frames, struct timespec *timestamp, int32_t clock_id); size_t audio_extn_utils_get_input_buffer_size(uint32_t, audio_format_t, int, int64_t, bool); +int audio_extn_utils_get_perf_mode_flag(void); #ifdef AUDIO_HW_LOOPBACK_ENABLED /* API to create audio patch */ int audio_extn_hw_loopback_create_audio_patch(struct audio_hw_device *dev, diff --git a/hal/audio_extn/compress_in.c b/hal/audio_extn/compress_in.c index bc630a37..6b525b08 100644 --- a/hal/audio_extn/compress_in.c +++ b/hal/audio_extn/compress_in.c @@ -332,6 +332,11 @@ int cin_configure_input_stream(struct stream_in *in, struct audio_config *in_con else cin_data->compr_config.codec->compr_passthr = PASSTHROUGH_GEN; + if (in->flags & AUDIO_INPUT_FLAG_FAST) { + ALOGD("%s: Setting latency mode to true", __func__); + cin_data->compr_config.codec->flags |= audio_extn_utils_get_perf_mode_flag(); + } + if ((in->flags & AUDIO_INPUT_FLAG_TIMESTAMP) || (in->flags & AUDIO_INPUT_FLAG_PASSTHROUGH)) { compress_config_set_timstamp_flag(&cin_data->compr_config); diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c index 8d9cd330..30bc10de 100644 --- a/hal/audio_extn/utils.c +++ b/hal/audio_extn/utils.c @@ -2949,6 +2949,15 @@ int audio_extn_utils_is_vendor_enhanced_fwk() return is_running_with_enhanced_fwk; } +int audio_extn_utils_get_perf_mode_flag(void) +{ +#ifdef COMPRESSED_PERF_MODE_FLAG + return COMPRESSED_PERF_MODE_FLAG; +#else + return 0; +#endif +} + size_t audio_extn_utils_get_input_buffer_size(uint32_t sample_rate, audio_format_t format, int channel_count, diff --git a/hal/audio_hw.c b/hal/audio_hw.c index 7519ee7d..d62c4cf2 100644 --- a/hal/audio_hw.c +++ b/hal/audio_hw.c @@ -7380,6 +7380,11 @@ int adev_open_output_stream(struct audio_hw_device *dev, ALOGV("non-offload DIRECT_usecase ... usecase selected %d ", out->usecase); } + if (out->flags & AUDIO_OUTPUT_FLAG_FAST) { + ALOGD("%s: Setting latency mode to true", __func__); + out->compr_config.codec->flags |= audio_extn_utils_get_perf_mode_flag(); + } + if (out->usecase == USECASE_INVALID) { if (out->devices & AUDIO_DEVICE_OUT_AUX_DIGITAL && config->format == 0 && config->sample_rate == 0 && @@ -8713,6 +8718,8 @@ static int adev_open_input_stream(struct audio_hw_device *dev, } if (config->sample_rate == LOW_LATENCY_CAPTURE_SAMPLE_RATE && + (flags & AUDIO_INPUT_FLAG_TIMESTAMP) == 0 && + (flags & AUDIO_INPUT_FLAG_COMPRESS) == 0 && (flags & AUDIO_INPUT_FLAG_FAST) != 0) { is_low_latency = true; #if LOW_LATENCY_CAPTURE_USE_CASE