hal: Fix fragment size calculation for compress offload
Compress offload buffer duration changes was specific for
LE feature. Mask this change using vendor property to avoid
unintended modification of fragment size.
Change-Id: I14a7a4ee09d48329acba29f8e3eaae710e08d697
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 3761367..0807fb2 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -7651,9 +7651,11 @@
out->compr_config.fragments = DIRECT_PCM_NUM_FRAGMENTS;
- if ((config->offload_info.duration_us >= MIN_OFFLOAD_BUFFER_DURATION_MS * 1000) &&
- (config->offload_info.duration_us <= MAX_OFFLOAD_BUFFER_DURATION_MS * 1000))
- out->info.duration_us = (int64_t)config->offload_info.duration_us;
+ if (property_get_bool("vendor.audio.offload.buffer.duration.enabled", false)) {
+ if ((config->offload_info.duration_us >= MIN_OFFLOAD_BUFFER_DURATION_MS * 1000) &&
+ (config->offload_info.duration_us <= MAX_OFFLOAD_BUFFER_DURATION_MS * 1000))
+ out->info.duration_us = (int64_t)config->offload_info.duration_us;
+ }
/* Check if alsa session is configured with the same format as HAL input format,
* if not then derive correct fragment size needed to accomodate the
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 264c6f6..7420d07 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -8352,16 +8352,20 @@
}
/* Use client specified buffer size if mentioned */
- if ((info != NULL) &&
- (info->duration_us >= MIN_OFFLOAD_BUFFER_DURATION_MS) &&
- (info->duration_us <= MAX_OFFLOAD_BUFFER_DURATION_MS)) {
- duration_ms = info->duration_us / 1000;
- channel_count = audio_channel_count_from_in_mask(info->channel_mask);
+ if (property_get_bool("vendor.audio.offload.buffer.duration.enabled", false)) {
+ if ((info != NULL) &&
+ (info->duration_us >= MIN_OFFLOAD_BUFFER_DURATION_MS) &&
+ (info->duration_us <= MAX_OFFLOAD_BUFFER_DURATION_MS)) {
+ duration_ms = info->duration_us / 1000;
+ channel_count = audio_channel_count_from_in_mask(info->channel_mask);
- new_fragment_size = (duration_ms * info->sample_rate * channel_count * audio_bytes_per_sample(info->format)) / 1000;
- ALOGI("%s:: Overwriting offload buffer size with client requested size old:%d new:%d", __func__, fragment_size, new_fragment_size);
+ new_fragment_size = (duration_ms * info->sample_rate * channel_count *
+ audio_bytes_per_sample(info->format)) / 1000;
+ ALOGI("%s:: Overwriting offload buffer size with client requested size old:%d new:%d",
+ __func__, fragment_size, new_fragment_size);
- fragment_size = new_fragment_size;
+ fragment_size = new_fragment_size;
+ }
}
if (info != NULL) {