Merge "policy-hal: add custom audio policy"
diff --git a/hal/audio_extn/audio_extn.h b/hal/audio_extn/audio_extn.h
index 8c893c6..b9ea90b 100644
--- a/hal/audio_extn/audio_extn.h
+++ b/hal/audio_extn/audio_extn.h
@@ -48,7 +48,7 @@
#define audio_is_offload_pcm(format) (0)
#define OFFLOAD_USE_SMALL_BUFFER false
#else
-#define OFFLOAD_USE_SMALL_BUFFER (info->use_small_bufs)
+#define OFFLOAD_USE_SMALL_BUFFER ((info->format & AUDIO_FORMAT_PCM_OFFLOAD) == AUDIO_FORMAT_PCM_OFFLOAD)
#endif
#ifndef AFE_PROXY_ENABLED
@@ -97,7 +97,8 @@
#endif
#ifdef PCM_OFFLOAD_ENABLED_24
-#define PCM_OUTPUT_BIT_WIDTH (config->offload_info.bit_width)
+#define PCM_OUTPUT_BIT_WIDTH (((config->offload_info.format & AUDIO_FORMAT_PCM_24_BIT_OFFLOAD) == \
+ (AUDIO_FORMAT_PCM_24_BIT_OFFLOAD)) ? 24 : CODEC_BACKEND_DEFAULT_BIT_WIDTH)
#else
#define PCM_OUTPUT_BIT_WIDTH (CODEC_BACKEND_DEFAULT_BIT_WIDTH)
#endif
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index e50e1b6..2d92bf8 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -649,7 +649,7 @@
(usecase->out_snd_device != snd_device || force_routing) &&
usecase->devices & AUDIO_DEVICE_OUT_ALL_CODEC_BACKEND &&
usecase_backend_idx == backend_idx) {
- ALOGV("%s: Usecase (%s) is active on (%s) - disabling ..", __func__,
+ ALOGD("%s: Usecase (%s) is active on (%s) - disabling ..", __func__,
use_case_table[usecase->id],
platform_get_snd_device_name(usecase->out_snd_device));
disable_audio_route(adev, usecase);
@@ -681,10 +681,9 @@
specified usecase to new snd devices */
list_for_each(node, &adev->usecase_list) {
usecase = node_to_item(node, struct audio_usecase, list);
- /* Update the out_snd_device only before enabling the audio route */
- if (switch_device[usecase->id] ) {
- usecase->out_snd_device = snd_device;
- if (usecase->type != VOICE_CALL)
+ /* Update the out_snd_device only for the usecases that are enabled here */
+ if (switch_device[usecase->id] && (usecase->type != VOICE_CALL)) {
+ usecase->out_snd_device = snd_device;
enable_audio_route(adev, usecase);
}
}
@@ -894,7 +893,6 @@
usecase->stream.out);
if (usecase->stream.out == adev->primary_output &&
adev->active_input &&
- adev->active_input->source == AUDIO_SOURCE_VOICE_COMMUNICATION &&
out_snd_device != usecase->out_snd_device) {
select_devices(adev, adev->active_input->usecase);
}
@@ -2897,7 +2895,7 @@
else
out->compr_config.codec->id =
get_snd_codec_id(config->offload_info.format);
- if (audio_is_offload_pcm(config->offload_info.format)) {
+ if ((config->offload_info.format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM_OFFLOAD) {
out->compr_config.fragment_size =
platform_get_pcm_offload_buffer_size(&config->offload_info);
} else if (audio_extn_dolby_is_passthrough_stream(out->flags)) {
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 02cb673..873dd4f 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -1773,7 +1773,7 @@
{
na_props.platform_na_prop_enabled = na_props.ui_na_prop_enabled
= codec_support;
- ALOGV("%s: na_props.platform_na_prop_enabled: %d", __func__,
+ ALOGD("%s: na_props.platform_na_prop_enabled: %d", __func__,
na_props.platform_na_prop_enabled);
return 0;
}
@@ -1824,10 +1824,15 @@
value, len);
if (ret >= 0) {
if (na_props.platform_na_prop_enabled) {
- if (!strncmp("true", value, sizeof("true")))
+ if (!strncmp("true", value, sizeof("true"))) {
na_props.ui_na_prop_enabled = true;
- else
+ ALOGD("%s: native audio feature enabled from UI",__func__);
+ }
+ else {
na_props.ui_na_prop_enabled = false;
+ ALOGD("%s: native audio feature disabled from UI",__func__);
+
+ }
str_parms_del(parms, AUDIO_PARAMETER_KEY_NATIVE_AUDIO);
@@ -1840,14 +1845,15 @@
(usecase->stream.out->devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
usecase->stream.out->devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) &&
OUTPUT_SAMPLING_RATE_44100 == usecase->stream.out->sample_rate) {
- select_devices(platform->adev, usecase->id);
- ALOGV("%s: triggering dynamic device switch for usecase: "
- "%d, device: %d", __func__, usecase->id,
+ ALOGD("%s: triggering dynamic device switch for usecase(%d: %s)"
+ " stream(%p), device(%d)", __func__, usecase->id,
+ use_case_table[usecase->id], usecase->stream,
usecase->stream.out->devices);
+ select_devices(platform->adev, usecase->id);
}
}
} else {
- ALOGV("%s: native audio not supported: %d", __func__,
+ ALOGD("%s: native audio not supported: %d", __func__,
na_props.platform_na_prop_enabled);
}
}
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 6c377b7..4df1c01 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -1737,7 +1737,7 @@
int ret = 0;
na_props.platform_na_prop_enabled = na_props.ui_na_prop_enabled
= codec_support;
- ALOGV("%s: na_props.platform_na_prop_enabled: %d", __func__,
+ ALOGD("%s: na_props.platform_na_prop_enabled: %d", __func__,
na_props.platform_na_prop_enabled);
return ret;
}
@@ -1788,10 +1788,15 @@
value, len);
if (ret >= 0) {
if (na_props.platform_na_prop_enabled) {
- if (!strncmp("true", value, sizeof("true")))
+ if (!strncmp("true", value, sizeof("true"))) {
na_props.ui_na_prop_enabled = true;
- else
+ ALOGD("%s: native audio feature enabled from UI",__func__);
+ }
+ else {
na_props.ui_na_prop_enabled = false;
+ ALOGD("%s: native audio feature disabled from UI",__func__);
+
+ }
str_parms_del(parms, AUDIO_PARAMETER_KEY_NATIVE_AUDIO);
@@ -1806,14 +1811,15 @@
(usecase->stream.out->devices & AUDIO_DEVICE_OUT_WIRED_HEADPHONE ||
usecase->stream.out->devices & AUDIO_DEVICE_OUT_WIRED_HEADSET) &&
OUTPUT_SAMPLING_RATE_44100 == usecase->stream.out->sample_rate) {
- select_devices(platform->adev, usecase->id);
- ALOGV("%s: triggering dynamic device switch for usecase: "
- "%d, device: %d", __func__, usecase->id,
+ ALOGD("%s: triggering dynamic device switch for usecase(%d: %s)"
+ " stream(%p), device(%d)", __func__, usecase->id,
+ use_case_table[usecase->id], usecase->stream,
usecase->stream.out->devices);
+ select_devices(platform->adev, usecase->id);
}
}
} else {
- ALOGV("%s: native audio not supported: %d", __func__,
+ ALOGD("%s: native audio not supported: %d", __func__,
na_props.platform_na_prop_enabled);
}
}