audio: Audio Mixer module fail case summary [1/1]

PD#SWPL-194277

Problem:
When input format is dolby, Aux and app stream loudness is not
Attenuated.
When input format is pcm, Aux and app stream loudness is Attenuated 8dB.

Solution:
Regardless of the input format, Aux and app stream loudness is
Attenuated 8dB.

Verify:
yocto-t5w

Change-Id: I34fe36cf3fe5b84ec485bf941c0ce54922a52e64
Signed-off-by: yayun.shi <yayun.shi@amlogic.com>
diff --git a/audio_hal/aml_audio_ms12_render.c b/audio_hal/aml_audio_ms12_render.c
index 041c0b4..e75e905 100644
--- a/audio_hal/aml_audio_ms12_render.c
+++ b/audio_hal/aml_audio_ms12_render.c
@@ -84,7 +84,9 @@
     {
         /*begin to write, clear the total write*/
         total_write = 0;
-        audio_input_loudness_control(aml_out, abuffer->buffer, abuffer->size);
+        if (audio_is_linear_pcm(adev->ms12.main_input_fmt)) {
+            audio_input_loudness_control(aml_out, abuffer->buffer, abuffer->size);
+        }
 re_write:
         if (adev->debug_flag > 1) {
             ALOGI("%s dolby_ms12_main_process before write_bytes %d, pts %"PRIu64"!\n", __func__, write_bytes, abuffer->pts);
@@ -372,6 +374,9 @@
 
         //nondolby codec: then use mixer to mix ad
         if (eDolbyMS12Lib == adev->dolby_lib_type) {//use ms12 to mix ad pcm
+            if (audio_is_linear_pcm(adev->ms12.main_input_fmt)) {
+                audio_input_loudness_control(aml_out, out_abuffer.buffer, out_abuffer.size);
+            }
             ret = ms12_ad_process(stream, &out_abuffer);
             if (0 != ret) {
                 AM_LOGE("dolby_ms12_ad_process failed");
diff --git a/audio_hal/audio_hw_ms12_v2.c b/audio_hal/audio_hw_ms12_v2.c
index cfb488c..3b01406 100644
--- a/audio_hal/audio_hw_ms12_v2.c
+++ b/audio_hal/audio_hw_ms12_v2.c
@@ -1376,18 +1376,17 @@
  *     use_size: buffer used size
  */
 
+//Attenuate the signal by 8dB
 int audio_input_loudness_control (struct aml_stream_out *aml_out, void *buffer, size_t bytes) {
     struct aml_audio_device *adev = aml_out->dev;
     int channels = audio_channel_count_from_out_mask(aml_out->hal_channel_mask);
 
-    if (audio_is_linear_pcm(adev->ms12.main_input_fmt)) {
-        aml_out->drc_mode_volume = DbToAmpl(PRE_ATTENUATION_VALUES_DB);
-        apply_volume_fade(aml_out->last_drc_mode_volume, aml_out->drc_mode_volume, buffer, sizeof(uint16_t), channels, bytes);
-        if (aml_out->last_drc_mode_volume != aml_out->drc_mode_volume) {
-            ALOGI("[%s:%d](LINE_MODE) aml_out=%p cur_volume=%f last_volume=%f channels=%d bytes=%zu",
-                __func__, __LINE__, aml_out, aml_out->drc_mode_volume , aml_out->last_drc_mode_volume, channels, bytes);
-            aml_out->last_drc_mode_volume = aml_out->drc_mode_volume;
-        }
+    aml_out->drc_mode_volume = DbToAmpl(PRE_ATTENUATION_VALUES_DB);
+    apply_volume_fade(aml_out->last_drc_mode_volume, aml_out->drc_mode_volume, buffer, sizeof(uint16_t), channels, bytes);
+    if (aml_out->last_drc_mode_volume != aml_out->drc_mode_volume) {
+        ALOGI("[%s:%d](Attenuate 8dB) aml_out=%p cur_volume=%f last_volume=%f channels=%d bytes=%zu",
+            __func__, __LINE__, aml_out, aml_out->drc_mode_volume , aml_out->last_drc_mode_volume, channels, bytes);
+        aml_out->last_drc_mode_volume = aml_out->drc_mode_volume;
     }
 }