Merge "hal: Limit multichannel clips >48khz to 48Khz"
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 98b2672..e7e2418 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -421,6 +421,7 @@
audio_format_t format,
uint32_t sample_rate,
uint32_t bit_width,
+ audio_channel_mask_t channel_mask,
struct stream_app_type_cfg *app_type_cfg);
int audio_extn_utils_send_app_type_cfg(struct audio_usecase *usecase);
void audio_extn_utils_send_audio_calibration(struct audio_device *adev,
diff --git a/hal/audio_extn/utils.c b/hal/audio_extn/utils.c
index 82b596f..3a0b6fd 100644
--- a/hal/audio_extn/utils.c
+++ b/hal/audio_extn/utils.c
@@ -452,12 +452,14 @@
audio_format_t format,
uint32_t sample_rate,
uint32_t bit_width,
+ audio_channel_mask_t channel_mask,
struct stream_app_type_cfg *app_type_cfg)
{
struct listnode *node_i, *node_j, *node_k;
struct streams_output_cfg *so_info;
struct stream_format *sf_info;
struct stream_sample_rate *ss_info;
+ char value[PROPERTY_VALUE_MAX] = {0};
if ((24 == bit_width) &&
(devices & AUDIO_DEVICE_OUT_SPEAKER)) {
@@ -468,6 +470,16 @@
ALOGI("%s Allowing 24-bit playback on speaker ONLY at default sampling rate", __func__);
}
+ property_get("audio.playback.mch.downsample",value,"");
+ if (!strncmp("true", value, sizeof("true"))) {
+ if ((popcount(channel_mask) > 2) &&
+ (sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
+ !(flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH)) {
+ sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ ALOGD("%s: MCH session defaulting sample rate to %d",
+ __func__, sample_rate);
+ }
+ }
ALOGV("%s: flags: %x, format: %x sample_rate %d",
__func__, flags, format, sample_rate);
list_for_each(node_i, streams_output_cfg_list) {
@@ -509,6 +521,7 @@
struct mixer_ctl *ctl;
int pcm_device_id, acdb_dev_id, snd_device = usecase->out_snd_device;
int32_t sample_rate = DEFAULT_OUTPUT_SAMPLING_RATE;
+ char value[PROPERTY_VALUE_MAX] = {0};
ALOGV("%s", __func__);
@@ -558,6 +571,14 @@
sample_rate = out->app_type_cfg.sample_rate;
}
+ property_get("audio.playback.mch.downsample",value,"");
+ if (!strncmp("true", value, sizeof("true"))) {
+ if ((popcount(out->channel_mask) > 2) &&
+ (out->sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
+ !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH))
+ sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ }
+
app_type_cfg[len++] = out->app_type_cfg.app_type;
app_type_cfg[len++] = acdb_dev_id;
if (((out->format == AUDIO_FORMAT_E_AC3) ||
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index b3812a8..435d5ba 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -954,6 +954,7 @@
usecase->stream.out->format,
usecase->stream.out->sample_rate,
usecase->stream.out->bit_width,
+ usecase->stream.out->channel_mask,
&usecase->stream.out->app_type_cfg);
ALOGI("%s Selected apptype: %d", __func__, usecase->stream.out->app_type_cfg.app_type);
}
@@ -2978,7 +2979,8 @@
audio_extn_utils_update_stream_app_type_cfg(adev->platform,
&adev->streams_output_cfg_list,
devices, flags, format, out->sample_rate,
- out->bit_width, &out->app_type_cfg);
+ out->bit_width, out->channel_mask,
+ &out->app_type_cfg);
if ((out->usecase == USECASE_AUDIO_PLAYBACK_PRIMARY) ||
(flags & AUDIO_OUTPUT_FLAG_PRIMARY)) {
/* Ensure the default output is not selected twice */
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 4015f92..ad95710 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -3469,6 +3469,7 @@
struct stream_out *out = NULL;
unsigned int bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
unsigned int sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ char value[PROPERTY_VALUE_MAX] = {0};
// For voice calls use default configuration
// force routing is not required here, caller will do it anyway
@@ -3508,6 +3509,22 @@
if (16 == bit_width) {
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
}
+
+ //check if mulitchannel clip needs to be down sampled to 48k
+ property_get("audio.playback.mch.downsample",value,"");
+ if (!strncmp("true", value, sizeof("true"))) {
+ out = usecase->stream.out;
+ if ((popcount(out->channel_mask) > 2) &&
+ (out->sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
+ !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH)) {
+ sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ /* update out sample rate to reflect current backend sample rate */
+ out->sample_rate = sample_rate;
+ ALOGD("%s: MCH session defaulting sample rate to %d",
+ __func__, sample_rate);
+ }
+ }
+
// 24 bit playback on speakers is allowed through 48 khz backend only
// bit width re-configured based on platform info
if ((24 == bit_width) &&
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index cc2d962..75f07fe 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -3132,6 +3132,7 @@
struct stream_out *out = NULL;
unsigned int bit_width = CODEC_BACKEND_DEFAULT_BIT_WIDTH;
unsigned int sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ char value[PROPERTY_VALUE_MAX] = {0};
// For voice calls use default configuration
// force routing is not required here, caller will do it anyway
@@ -3171,6 +3172,21 @@
if (16 == bit_width) {
sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
}
+
+ //check if mulitchannel clip needs to be down sampled to 48k
+ property_get("audio.playback.mch.downsample",value,"");
+ if (!strncmp("true", value, sizeof("true"))) {
+ out = usecase->stream.out;
+ if ((popcount(out->channel_mask) > 2) &&
+ (out->sample_rate > CODEC_BACKEND_DEFAULT_SAMPLE_RATE) &&
+ !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_PASSTHROUGH)) {
+ /* update out sample rate to reflect current backend sample rate */
+ sample_rate = CODEC_BACKEND_DEFAULT_SAMPLE_RATE;
+ ALOGD("%s: MCH session defaulting sample rate to %d",
+ __func__, sample_rate);
+ }
+ }
+
// 24 bit playback on speakers is allowed through 48 khz backend only
// bit width re-configured based on platform info
if ((24 == bit_width) &&