Merge "hal: Fix test app crash issue"
diff --git a/configs/sdm845/sdm845.mk b/configs/sdm845/sdm845.mk
index 38a84c1..9d20d48 100644
--- a/configs/sdm845/sdm845.mk
+++ b/configs/sdm845/sdm845.mk
@@ -232,6 +232,7 @@
 vendor.audio.adm.buffering.ms=2
 
 #enable use of display-port for voice usecases
+PRODUCT_PROPERTY_OVERRIDES += \
 vendor.audio.enable.dp.for.voice=false
 
 # for HIDL related packages
diff --git a/hal/Makefile.am b/hal/Makefile.am
index 0096bf7..8ab3e7c 100644
--- a/hal/Makefile.am
+++ b/hal/Makefile.am
@@ -215,4 +215,5 @@
 audio_primary_default_la_CFLAGS += -DINT_MAX=0x7fffffff
 audio_primary_default_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
 audio_primary_default_la_CFLAGS += -DLINUX_ENABLED $(TARGET_CFLAGS) -DAUDIO_EXTN_FORMATS_ENABLED
+audio_primary_default_la_CFLAGS += -DNDEBUG
 audio_primary_default_la_LDFLAGS = -module -shared -avoid-version
diff --git a/hal/audio_extn/spkr_protection.c b/hal/audio_extn/spkr_protection.c
index ea4d856..589a391 100644
--- a/hal/audio_extn/spkr_protection.c
+++ b/hal/audio_extn/spkr_protection.c
@@ -70,8 +70,8 @@
 #define MIN_RESISTANCE_LOOKUP (3.2)
 #define MAX_RESISTANCE_LOOKUP (8)
 #define SPV3_LOOKUP_TABLE_ROWS (49)
-/* default limiter threshold is 0dB */
-#define DEFAULT_LIMITER_TH (0x0)
+/* default limiter threshold is 0dB(0x7FFFFFF in natural value) */
+#define DEFAULT_LIMITER_TH (0x07FFFFFF)
 #define AFE_API_VERSION_SUPPORT_SPV3 (0x2)
 enum spv3_boost_max_state {
     BOOST_NO_MAX_STATE,
@@ -275,15 +275,15 @@
 
 /* 3.2ohm : 0.1ohm : 8ohm lookup table */
 static int spv3_limiter_th_q27_table[SPV3_LOOKUP_TABLE_ROWS] = {
-    -526133494, -508685189, -491236884, -473788580, -457682452, -441576325,
-    -426812375, -410706248, -395942298, -382520525, -367756575, -354334802,
-    -340913029, -327491256, -315411661, -301989888, -289910292, -277830697,
-    -265751101, -255013683, -242934088, -232196669, -221459251, -210721833,
-    -199984415, -190589174, -179851756, -170456515, -159719096, -150323855,
-    -140928614, -131533373, -122138132, -114085069, -104689828, -95294587,
-    -87241523,  -79188460,  -69793219,  -61740155,  -53687091,  -45634028,
-    -37580964,  -29527900,  -22817014,  -14763950,  -6710886,   0,
-    0
+    85469248, 86758070, 88066327, 89394311, 90637910, 91898809,
+    93070036, 94364769, 95567425, 96674043, 97906130, 99039829,
+    100186656, 101346763, 102402340, 103588104, 104667026, 105757185,
+    106858699, 107847451, 108970736, 109979029, 110996653, 112023692,
+    113060235, 113975074, 115029672, 115960448, 117033416, 117980405,
+    118935056, 119897432, 120867596, 121705410, 122690202, 123682964,
+    124540293, 125403565, 126418282, 127294571, 128176935, 129065415,
+    129960054, 130860894, 131616362, 132528683, 133447328, 134217728,
+    134217728
 };
 static struct speaker_prot_session handle;
 static int vi_feed_no_channels;
diff --git a/hal/audio_hw.c b/hal/audio_hw.c
index 4506115..2ff15a7 100644
--- a/hal/audio_hw.c
+++ b/hal/audio_hw.c
@@ -2709,7 +2709,13 @@
             break;
         }
 
-        if (out->compr == NULL) {
+        // allow OFFLOAD_CMD_ERROR reporting during standby
+        // this is needed to handle failures during compress_open
+        // Note however that on a pause timeout, the stream is closed
+        // and no offload usecase will be active. Therefore this
+        // special case is needed for compress_open failures alone
+        if (cmd->cmd != OFFLOAD_CMD_ERROR &&
+            out->compr == NULL) {
             ALOGE("%s: Compress handle is NULL", __func__);
             free(cmd);
             pthread_cond_signal(&out->cond);
@@ -3079,7 +3085,7 @@
                                    COMPRESS_IN, &out->compr_config);
         ATRACE_END();
         if (out->compr && !is_compress_ready(out->compr)) {
-            ALOGE("%s: %s", __func__, compress_get_error(out->compr));
+            ALOGE("%s: failed /w error %s", __func__, compress_get_error(out->compr));
             compress_close(out->compr);
             out->compr = NULL;
             ret = -EIO;
@@ -3413,16 +3419,22 @@
 static int out_on_error(struct audio_stream *stream)
 {
     struct stream_out *out = (struct stream_out *)stream;
-    bool do_standby = false;
 
     lock_output_stream(out);
-    if (!out->standby) {
-        if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
-            stop_compressed_output_l(out);
-            send_offload_cmd_l(out, OFFLOAD_CMD_ERROR);
-        } else
-            do_standby = true;
+
+    // always send CMD_ERROR for offload streams, this
+    // is needed e.g. when SSR happens within compress_open
+    // since the stream is active, offload_callback_thread is also active.
+    if (out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
+        stop_compressed_output_l(out);
+        send_offload_cmd_l(out, OFFLOAD_CMD_ERROR);
     }
+
+    // for compress streams , if the stream is not in standby
+    // it will be triggered eventually from AF.
+    bool do_standby = !out->standby &&
+                      !(out->flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD);
+
     pthread_mutex_unlock(&out->lock);
 
     if (do_standby)
@@ -6539,6 +6551,47 @@
     return allowed;
 }
 
+static int adev_update_voice_comm_input_stream(struct stream_in *in,
+                                               struct audio_config *config)
+{
+    bool valid_rate = (config->sample_rate == 8000 ||
+                       config->sample_rate == 16000 ||
+                       config->sample_rate == 32000 ||
+                       config->sample_rate == 48000);
+    bool valid_ch = audio_channel_count_from_in_mask(in->channel_mask) == 1;
+
+#ifndef COMPRESS_VOIP_ENABLED
+    if (valid_rate && valid_ch) {
+        in->usecase = USECASE_AUDIO_RECORD_VOIP;
+        in->config = default_pcm_config_voip_copp;
+        in->config.period_size = VOIP_IO_BUF_SIZE(in->sample_rate,
+                                                  DEFAULT_VOIP_BUF_DURATION_MS,
+                                                  DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;
+    } else {
+        if (!valid_ch) config->channel_mask = 1;
+        if (!valid_rate) config->sample_rate = 48000;
+        return -EINVAL;
+    }
+    in->config.rate = config->sample_rate;
+    in->sample_rate = config->sample_rate;
+#else
+    //XXX needed for voice_extn_compress_voip_open_input_stream
+    in->config.rate = config->sample_rate;
+    if ((in->dev->mode == AUDIO_MODE_IN_COMMUNICATION ||
+         voice_extn_compress_voip_is_active(in->dev)) &&
+        (voice_extn_compress_voip_is_format_supported(in->format)) &&
+        valid_rate && valid_ch) {
+        voice_extn_compress_voip_open_input_stream(in);
+        // update rate entries to match config from AF
+        in->config.rate = config->sample_rate;
+        in->sample_rate = config->sample_rate;
+    } else {
+        ALOGW("%s compress voip not active, use defaults", __func__);
+    }
+#endif
+    return 0;
+}
+
 static int adev_open_input_stream(struct audio_hw_device *dev,
                                   audio_io_handle_t handle,
                                   audio_devices_t devices,
@@ -6621,9 +6674,6 @@
         goto err_open;
     }
 
-    /* restrict 24 bit capture for unprocessed source only
-     * for other sources if 24 bit requested reject 24 and set 16 bit capture only
-     */
     if (is_usb_dev && may_use_hifi_record) {
         /* HiFi record selects an appropriate format, channel, rate combo
            depending on sink capabilities*/
@@ -6642,9 +6692,7 @@
             goto err_open;
         }
         channel_count = audio_channel_count_from_in_mask(config->channel_mask);
-    }
-
-    if (config->format == AUDIO_FORMAT_DEFAULT) {
+    } else if (config->format == AUDIO_FORMAT_DEFAULT) {
         config->format = AUDIO_FORMAT_PCM_16_BIT;
     } else if ((config->format == AUDIO_FORMAT_PCM_FLOAT) ||
                (config->format == AUDIO_FORMAT_PCM_32_BIT) ||
@@ -6706,6 +6754,7 @@
     } else if (in->realtime) {
         in->config = pcm_config_audio_capture_rt;
         in->config.format = pcm_format_from_audio_format(config->format);
+        in->config.channels = channel_count;
         in->sample_rate = in->config.rate;
         in->af_period_multiplier = af_period_multiplier;
     } else if (is_usb_dev && may_use_hifi_record) {
@@ -6760,40 +6809,6 @@
         ret = audio_extn_cin_configure_input_stream(in);
         if (ret)
             goto err_open;
-    } else if (in->source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
-        bool valid_rate = (config->sample_rate == 8000 ||
-                           config->sample_rate == 16000 ||
-                           config->sample_rate == 32000 ||
-                           config->sample_rate == 48000);
-        bool valid_ch = audio_channel_count_from_in_mask(in->channel_mask) == 1;
-        //XXX needed for voice_extn_compress_voip_open_input_stream
-        in->config.rate = config->sample_rate;
-#ifndef COMPRESS_VOIP_ENABLED
-        if (valid_rate && valid_ch) {
-            in->usecase = USECASE_AUDIO_RECORD_VOIP;
-            in->config = default_pcm_config_voip_copp;
-            in->config.period_size = VOIP_IO_BUF_SIZE(in->sample_rate,
-                                                      DEFAULT_VOIP_BUF_DURATION_MS,
-                                                      DEFAULT_VOIP_BIT_DEPTH_BYTE)/2;
-        }
-#else
-        if ((in->dev->mode == AUDIO_MODE_IN_COMMUNICATION ||
-             voice_extn_compress_voip_is_active(in->dev)) &&
-            (voice_extn_compress_voip_is_format_supported(in->format)) &&
-            valid_rate && valid_ch) {
-            voice_extn_compress_voip_open_input_stream(in);
-        }
-#endif
-        else {
-            ALOGE("%s AUDIO_SOURCE_VOICE_COMMUNICATION invalid args", __func__);
-            ret = -EINVAL;
-            if (!valid_ch) config->channel_mask = 1;
-            if (!valid_rate) config->sample_rate = 48000;
-            goto err_open;
-        }
-        // update back to whatever was overwritten
-        in->config.rate = config->sample_rate;
-        in->sample_rate = config->sample_rate;
     } else {
         in->config = pcm_config_audio_capture;
         in->config.rate = config->sample_rate;
@@ -6807,11 +6822,22 @@
                                             channel_count,
                                             is_low_latency);
         in->config.period_size = buffer_size / frame_size;
+
+        if (in->source == AUDIO_SOURCE_VOICE_COMMUNICATION) {
+            /* optionally use VOIP usecase depending on config(s) */
+            ret = adev_update_voice_comm_input_stream(in, config);
+        }
+
+        if (ret) {
+            ALOGE("%s AUDIO_SOURCE_VOICE_COMMUNICATION invalid args", __func__);
+            goto err_open;
+        }
     }
     audio_extn_utils_update_stream_input_app_type_cfg(adev->platform,
                                                 &adev->streams_input_cfg_list,
-                                                devices, flags, in->format, in->sample_rate,
-                                                in->bit_width, in->profile, &in->app_type_cfg);
+                                                devices, flags, in->format,
+                                                in->sample_rate, in->bit_width,
+                                                in->profile, &in->app_type_cfg);
 
     /* This stream could be for sound trigger lab,
        get sound trigger pcm if present */
diff --git a/hal/audio_hw.h b/hal/audio_hw.h
index c5ee848..7885b97 100644
--- a/hal/audio_hw.h
+++ b/hal/audio_hw.h
@@ -64,6 +64,9 @@
 #define ANC_FLAG	     0x00000001
 #define DMIC_FLAG            0x00000002
 #define QMIC_FLAG            0x00000004
+/* Include TMIC Flag after existing QMIC flag to avoid backward compatibility
+ * issues since they are bit masked */
+#define TMIC_FLAG            0x00000008
 #define TTY_MODE_OFF         0x00000010
 #define TTY_MODE_FULL        0x00000020
 #define TTY_MODE_VCO         0x00000040
diff --git a/hal/msm8916/platform.c b/hal/msm8916/platform.c
index 56d9aec..c31a8d8 100644
--- a/hal/msm8916/platform.c
+++ b/hal/msm8916/platform.c
@@ -6777,7 +6777,7 @@
          *sample_rate = stream_sr;
 
      if (snd_device == SND_DEVICE_OUT_HDMI)
-         *sample_rate = platform_get_supported_sampling_rate_on_hdmi(stream_sr);
+         *sample_rate = platform_get_supported_copp_sampling_rate(stream_sr);
 
      ALOGI("sn_device %d device sr %d stream sr %d copp sr %d", snd_device, device_sr, stream_sr
 , *sample_rate);
@@ -7882,7 +7882,7 @@
     return MAX_CODEC_BACKENDS;
 }
 
-int platform_get_supported_sampling_rate_on_hdmi(uint32_t stream_sr)
+int platform_get_supported_copp_sampling_rate(uint32_t stream_sr)
 {
     int sample_rate;
     switch (stream_sr){
diff --git a/hal/msm8974/platform.c b/hal/msm8974/platform.c
index 891f262..4a6ba5b 100644
--- a/hal/msm8974/platform.c
+++ b/hal/msm8974/platform.c
@@ -525,7 +525,11 @@
     [SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS] = "quad-mic",
     [SND_DEVICE_IN_VOICE_REC_QMIC_FLUENCE] = "quad-mic",
     [SND_DEVICE_IN_THREE_MIC] = "three-mic",
+    [SND_DEVICE_IN_HANDSET_TMIC_FLUENCE_PRO] = "three-mic",
     [SND_DEVICE_IN_HANDSET_TMIC] = "three-mic",
+    [SND_DEVICE_IN_HANDSET_TMIC_AEC] = "three-mic",
+    [SND_DEVICE_IN_HANDSET_TMIC_NS] = "three-mic",
+    [SND_DEVICE_IN_HANDSET_TMIC_AEC_NS] = "three-mic",
     [SND_DEVICE_IN_VOICE_REC_TMIC] = "three-mic",
     [SND_DEVICE_IN_UNPROCESSED_MIC] = "unprocessed-mic",
     [SND_DEVICE_IN_UNPROCESSED_STEREO_MIC] = "unprocessed-stereo-mic",
@@ -684,7 +688,11 @@
     [SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS] = 129,
     [SND_DEVICE_IN_VOICE_REC_QMIC_FLUENCE] = 125,
     [SND_DEVICE_IN_THREE_MIC] = 46, /* for APSS Surround Sound Recording */
-    [SND_DEVICE_IN_HANDSET_TMIC] = 125, /* for 3mic recording with fluence */
+    [SND_DEVICE_IN_HANDSET_TMIC_FLUENCE_PRO] = 125,
+    [SND_DEVICE_IN_HANDSET_TMIC] = 153,
+    [SND_DEVICE_IN_HANDSET_TMIC_AEC] = 154,
+    [SND_DEVICE_IN_HANDSET_TMIC_NS] = 155,
+    [SND_DEVICE_IN_HANDSET_TMIC_AEC_NS] = 156,
     [SND_DEVICE_IN_VOICE_REC_TMIC] = 125,
     [SND_DEVICE_IN_UNPROCESSED_MIC] = 143,
     [SND_DEVICE_IN_UNPROCESSED_STEREO_MIC] = 144,
@@ -827,7 +835,11 @@
     {TO_NAME_INDEX(SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS)},
     {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_QMIC_FLUENCE)},
     {TO_NAME_INDEX(SND_DEVICE_IN_THREE_MIC)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC_FLUENCE_PRO)},
     {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC_AEC)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC_NS)},
+    {TO_NAME_INDEX(SND_DEVICE_IN_HANDSET_TMIC_AEC_NS)},
     {TO_NAME_INDEX(SND_DEVICE_IN_VOICE_REC_TMIC)},
     {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_MIC)},
     {TO_NAME_INDEX(SND_DEVICE_IN_UNPROCESSED_STEREO_MIC)},
@@ -1507,7 +1519,11 @@
     hw_interface_table[SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_VOICE_REC_QMIC_FLUENCE] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_THREE_MIC] = strdup("SLIMBUS_0_TX");
+    hw_interface_table[SND_DEVICE_IN_HANDSET_TMIC_FLUENCE_PRO] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_HANDSET_TMIC] = strdup("SLIMBUS_0_TX");
+    hw_interface_table[SND_DEVICE_IN_HANDSET_TMIC_AEC] = strdup("SLIMBUS_0_TX");
+    hw_interface_table[SND_DEVICE_IN_HANDSET_TMIC_NS] = strdup("SLIMBUS_0_TX");
+    hw_interface_table[SND_DEVICE_IN_HANDSET_TMIC_AEC_NS] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_VOICE_REC_TMIC] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_UNPROCESSED_MIC] = strdup("SLIMBUS_0_TX");
     hw_interface_table[SND_DEVICE_IN_UNPROCESSED_STEREO_MIC] = strdup("SLIMBUS_0_TX");
@@ -2051,8 +2067,16 @@
     property_get("ro.vendor.audio.sdk.fluencetype", my_data->fluence_cap, "");
     if (!strncmp("fluencepro", my_data->fluence_cap, sizeof("fluencepro"))) {
         my_data->fluence_type = FLUENCE_QUAD_MIC | FLUENCE_DUAL_MIC;
+
+        if (property_get_bool("persist.vendor.audio.fluence.tmic.enabled",false)) {
+            my_data->fluence_type |= FLUENCE_TRI_MIC;
+        }
     } else if (!strncmp("fluence", my_data->fluence_cap, sizeof("fluence"))) {
         my_data->fluence_type = FLUENCE_DUAL_MIC;
+
+        if (property_get_bool("persist.vendor.audio.fluence.tmic.enabled",false)) {
+            my_data->fluence_type |= FLUENCE_TRI_MIC;
+        }
     } else {
         my_data->fluence_type = FLUENCE_NONE;
     }
@@ -2359,12 +2383,17 @@
         my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl =
             strdup("INT0_MI2S_RX SampleRate");
 
-    }
+    } else {
 
-    my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].bitwidth_mixer_ctl =
-        strdup("SLIM_0_TX Format");
-    my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].samplerate_mixer_ctl =
-        strdup("SLIM_0_TX SampleRate");
+        my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].bitwidth_mixer_ctl =
+            strdup("SLIM_0_TX Format");
+        my_data->current_backend_cfg[DEFAULT_CODEC_TX_BACKEND].samplerate_mixer_ctl =
+            strdup("SLIM_0_TX SampleRate");
+        my_data->current_backend_cfg[HEADPHONE_BACKEND].bitwidth_mixer_ctl =
+            strdup("SLIM_6_RX Format");
+        my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl =
+            strdup("SLIM_6_RX SampleRate");
+    }
 
     my_data->current_backend_cfg[USB_AUDIO_TX_BACKEND].bitwidth_mixer_ctl =
         strdup("USB_AUDIO_TX Format");
@@ -2439,10 +2468,6 @@
         }
     }
 
-    my_data->current_backend_cfg[HEADPHONE_BACKEND].bitwidth_mixer_ctl =
-        strdup("SLIM_6_RX Format");
-    my_data->current_backend_cfg[HEADPHONE_BACKEND].samplerate_mixer_ctl =
-        strdup("SLIM_6_RX SampleRate");
     my_data->current_backend_cfg[HDMI_RX_BACKEND].bitwidth_mixer_ctl =
         strdup("HDMI_RX Bit Format");
     my_data->current_backend_cfg[HDMI_RX_BACKEND].samplerate_mixer_ctl =
@@ -3926,7 +3951,11 @@
             } else
                 snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS;
         } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
-            if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
+            if ((my_data->fluence_type & FLUENCE_TRI_MIC) &&
+                (my_data->source_mic_type & SOURCE_THREE_MIC)) {
+                snd_device = SND_DEVICE_IN_HANDSET_TMIC_AEC_NS;
+                adev->acdb_settings |= TMIC_FLAG;
+            } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
                 (my_data->source_mic_type & SOURCE_DUAL_MIC)) {
                 snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS;
                 adev->acdb_settings |= DMIC_FLAG;
@@ -3966,7 +3995,11 @@
             } else
                 snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC_NS;
         } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
-            if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
+            if ((my_data->fluence_type & FLUENCE_TRI_MIC) &&
+                (my_data->source_mic_type & SOURCE_THREE_MIC)) {
+                snd_device = SND_DEVICE_IN_HANDSET_TMIC_AEC_NS;
+                adev->acdb_settings |= TMIC_FLAG;
+            } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
                 (my_data->source_mic_type & SOURCE_DUAL_MIC)) {
                 snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC_NS;
                 adev->acdb_settings |= DMIC_FLAG;
@@ -3996,7 +4029,11 @@
             } else
                 snd_device = SND_DEVICE_IN_SPEAKER_MIC_AEC;
         } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
-            if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
+            if ((my_data->fluence_type & FLUENCE_TRI_MIC) &&
+                (my_data->source_mic_type & SOURCE_THREE_MIC)) {
+                snd_device = SND_DEVICE_IN_HANDSET_TMIC_AEC;
+                adev->acdb_settings |= TMIC_FLAG;
+            } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
                 (my_data->source_mic_type & SOURCE_DUAL_MIC)) {
                 snd_device = SND_DEVICE_IN_HANDSET_DMIC_AEC;
                 adev->acdb_settings |= DMIC_FLAG;
@@ -4026,7 +4063,11 @@
             } else
                 snd_device = SND_DEVICE_IN_SPEAKER_MIC_NS;
         } else if (in_device & AUDIO_DEVICE_IN_BUILTIN_MIC) {
-            if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
+            if ((my_data->fluence_type & FLUENCE_TRI_MIC) &&
+                (my_data->source_mic_type & SOURCE_THREE_MIC)) {
+                snd_device = SND_DEVICE_IN_HANDSET_TMIC_NS;
+                adev->acdb_settings |= TMIC_FLAG;
+            } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
                 (my_data->source_mic_type & SOURCE_DUAL_MIC)) {
                 snd_device = SND_DEVICE_IN_HANDSET_DMIC_NS;
                 adev->acdb_settings |= DMIC_FLAG;
@@ -4142,8 +4183,14 @@
                 if (audio_extn_hfp_is_active(adev))
                     platform_set_echo_reference(adev, true, out_device);
             } else {
-                snd_device = SND_DEVICE_IN_VOICE_DMIC;
-                adev->acdb_settings |= DMIC_FLAG;
+                if ((my_data->fluence_type & FLUENCE_TRI_MIC) &&
+                    (my_data->source_mic_type & SOURCE_THREE_MIC)) {
+                    snd_device = SND_DEVICE_IN_HANDSET_TMIC;
+                    adev->acdb_settings |= TMIC_FLAG;
+                } else { /* for FLUENCE_DUAL_MIC and SOURCE_DUAL_MIC */
+                    snd_device = SND_DEVICE_IN_VOICE_DMIC;
+                    adev->acdb_settings |= DMIC_FLAG;
+                }
             }
         } else if (out_device & AUDIO_DEVICE_OUT_WIRED_HEADSET) {
             snd_device = SND_DEVICE_IN_VOICE_HEADSET_MIC;
@@ -4314,6 +4361,9 @@
                     platform_set_echo_reference(adev, true, out_device);
                 } else if ((my_data->fluence_type & FLUENCE_QUAD_MIC) &&
                     (my_data->source_mic_type & SOURCE_THREE_MIC)) {
+                    snd_device = SND_DEVICE_IN_HANDSET_TMIC_FLUENCE_PRO;
+                } else if ((my_data->fluence_type & FLUENCE_TRI_MIC) &&
+                           (my_data->source_mic_type & SOURCE_THREE_MIC)) {
                     snd_device = SND_DEVICE_IN_HANDSET_TMIC;
                 } else if ((my_data->fluence_type & FLUENCE_DUAL_MIC) &&
                     (my_data->source_mic_type & SOURCE_DUAL_MIC)) {
@@ -6875,8 +6925,9 @@
      } else
          *sample_rate = stream_sr;
 
-    if (snd_device == SND_DEVICE_OUT_HDMI)
-        *sample_rate = platform_get_supported_sampling_rate_on_hdmi(stream_sr);
+    if ((snd_device == SND_DEVICE_OUT_HDMI) || (snd_device == SND_DEVICE_OUT_DISPLAY_PORT) ||
+                  (snd_device == SND_DEVICE_OUT_USB_HEADSET))
+        *sample_rate = platform_get_supported_copp_sampling_rate(stream_sr);
 
      ALOGI("sn_device %d device sr %d stream sr %d copp sr %d", snd_device, device_sr, stream_sr, *sample_rate);
 
@@ -7686,7 +7737,7 @@
 
     return MAX_CODEC_BACKENDS;
 }
-int platform_get_supported_sampling_rate_on_hdmi(uint32_t stream_sr)
+int platform_get_supported_copp_sampling_rate(uint32_t stream_sr)
 {
     int sample_rate;
     switch (stream_sr){
diff --git a/hal/msm8974/platform.h b/hal/msm8974/platform.h
index db86cdc..c2fb810 100644
--- a/hal/msm8974/platform.h
+++ b/hal/msm8974/platform.h
@@ -24,8 +24,9 @@
 enum {
     FLUENCE_NONE,
     FLUENCE_DUAL_MIC = 0x1,
-    FLUENCE_QUAD_MIC = 0x2,
-    FLUENCE_HEX_MIC = 0x4,
+    FLUENCE_TRI_MIC = 0x2,
+    FLUENCE_QUAD_MIC = 0x4,
+    FLUENCE_HEX_MIC = 0x8,
 };
 
 enum {
@@ -217,7 +218,11 @@
     SND_DEVICE_IN_SPEAKER_QMIC_AEC_NS,
     SND_DEVICE_IN_VOICE_REC_QMIC_FLUENCE,
     SND_DEVICE_IN_THREE_MIC,
+    SND_DEVICE_IN_HANDSET_TMIC_FLUENCE_PRO,
     SND_DEVICE_IN_HANDSET_TMIC,
+    SND_DEVICE_IN_HANDSET_TMIC_AEC,
+    SND_DEVICE_IN_HANDSET_TMIC_NS,
+    SND_DEVICE_IN_HANDSET_TMIC_AEC_NS,
     SND_DEVICE_IN_VOICE_REC_TMIC,
     SND_DEVICE_IN_UNPROCESSED_MIC,
     SND_DEVICE_IN_UNPROCESSED_STEREO_MIC,
diff --git a/hal/platform_api.h b/hal/platform_api.h
index 0674761..e72c6e9 100644
--- a/hal/platform_api.h
+++ b/hal/platform_api.h
@@ -184,7 +184,7 @@
 
 int platform_set_channel_allocation(void *platform, int channel_alloc);
 int platform_get_edid_info(void *platform);
-int platform_get_supported_sampling_rate_on_hdmi(uint32_t stream_sr);
+int platform_get_supported_copp_sampling_rate(uint32_t stream_sr);
 int platform_set_channel_map(void *platform, int ch_count, char *ch_map,
                              int snd_id);
 int platform_set_stream_channel_map(void *platform, audio_channel_mask_t channel_mask,
diff --git a/mm-audio/aenc-aac/qdsp6/Makefile.am b/mm-audio/aenc-aac/qdsp6/Makefile.am
index a79ce70..08c9bee 100644
--- a/mm-audio/aenc-aac/qdsp6/Makefile.am
+++ b/mm-audio/aenc-aac/qdsp6/Makefile.am
@@ -5,6 +5,7 @@
 AM_CFLAGS += -Wstrict-prototypes
 AM_CFLAGS += -Wno-trigraphs
 AM_CFLAGS += -g -O3
+AM_CFLAGS += -DNDEBUG
 
 AM_CPPFLAGS = -D__packed__=
 AM_CPPFLAGS += -DIMAGE_APPS_PROC
@@ -13,7 +14,7 @@
 AM_CPPFLAGS += -DFEATURE_LINUX
 AM_CPPFLAGS += -DFEATURE_NATIVELINUX
 AM_CPPFLAGS += -DFEATURE_DSM_DUP_ITEMS
-AM_CPPFLAGS += -D_DEBUG
+AM_CPPFLAGS += -DNDEBUG
 AM_CPPFLAGS += -Iinc
 AM_CPPFLAGS += -I ${WORKSPACE}/hardware/qcom/media/mm-core/inc/
 
diff --git a/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h b/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h
index 6041ffe..38e1d9a 100644
--- a/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h
+++ b/mm-audio/aenc-aac/qdsp6/inc/omx_aac_aenc.h
@@ -82,7 +82,7 @@
 
 
 #define PrintFrameHdr(i,bufHdr) \
-                           DEBUG_PRINT("i=%d OMX bufHdr[%p]buf[%p]size[%d]TS[%lld]nFlags[0x%x]\n",\
+                           DEBUG_DETAIL("i=%d OMX bufHdr[%p]buf[%p]size[%d]TS[%lld]nFlags[0x%x]\n",\
                            i,\
                            bufHdr,                                     \
                            ((OMX_BUFFERHEADERTYPE *)bufHdr)->pBuffer,   \
diff --git a/mm-audio/aenc-amrnb/qdsp6/Makefile.am b/mm-audio/aenc-amrnb/qdsp6/Makefile.am
index 13379a3..8becd07 100644
--- a/mm-audio/aenc-amrnb/qdsp6/Makefile.am
+++ b/mm-audio/aenc-amrnb/qdsp6/Makefile.am
@@ -19,7 +19,7 @@
 AM_CPPFLAGS += -I ${WORKSPACE}/hardware/qcom/media/mm-core/inc/
 
 AM_CPPFLAGS += -g
-AM_CPPFLAGS += -D_DEBUG
+AM_CPPFLAGS += -DNDEBUG
 AM_CPPFLAGS += -Iinc
 
 c_sources = src/omx_amr_aenc.cpp \
diff --git a/mm-audio/aenc-amrnb/qdsp6/inc/omx_amr_aenc.h b/mm-audio/aenc-amrnb/qdsp6/inc/omx_amr_aenc.h
index 8236c03..54935c7 100644
--- a/mm-audio/aenc-amrnb/qdsp6/inc/omx_amr_aenc.h
+++ b/mm-audio/aenc-amrnb/qdsp6/inc/omx_amr_aenc.h
@@ -84,7 +84,7 @@
 
 
 #define PrintFrameHdr(i,bufHdr) \
-                           DEBUG_PRINT("i=%d OMX bufHdr[%p]buf[%p]size[%d]TS[%lld]nFlags[0x%x]\n",\
+                           DEBUG_DETAIL("i=%d OMX bufHdr[%p]buf[%p]size[%d]TS[%lld]nFlags[0x%x]\n",\
                            i,\
                            bufHdr,                                     \
                            ((OMX_BUFFERHEADERTYPE *)bufHdr)->pBuffer,   \
diff --git a/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp b/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp
index 5532515..47b984c 100644
--- a/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp
+++ b/mm-audio/aenc-amrnb/qdsp6/src/omx_amr_aenc.cpp
@@ -512,13 +512,13 @@
         m_amr_pb_stats.fbd_cnt++;
         pthread_mutex_lock(&out_buf_count_lock);
         nNumOutputBuf--;
-        DEBUG_PRINT("FBD CB:: nNumOutputBuf=%d out_buf_len=%u fbd_cnt=%u\n",\
+        DEBUG_DETAIL("FBD CB:: nNumOutputBuf=%d out_buf_len=%u fbd_cnt=%u\n",\
                     nNumOutputBuf,
                     m_amr_pb_stats.tot_out_buf_len,
                     m_amr_pb_stats.fbd_cnt);
         m_amr_pb_stats.tot_out_buf_len += bufHdr->nFilledLen;
         m_amr_pb_stats.tot_pb_time     = bufHdr->nTimeStamp;
-        DEBUG_PRINT("FBD:in_buf_len=%u out_buf_len=%u\n",
+        DEBUG_DETAIL("FBD:in_buf_len=%u out_buf_len=%u\n",
                     m_amr_pb_stats.tot_in_buf_len,
                     m_amr_pb_stats.tot_out_buf_len);
 
@@ -3233,7 +3233,7 @@
         return OMX_ErrorBadParameter;
     }
     *state = m_state;
-    DEBUG_PRINT("Returning the state %d\n",*state);
+    DEBUG_DETAIL("Returning the state %d\n",*state);
     return OMX_ErrorNone;
 }
 
@@ -3975,12 +3975,12 @@
  @return error status
  */
 OMX_ERRORTYPE  omx_amr_aenc::empty_this_buffer(
-				OMX_IN OMX_HANDLETYPE         hComp,
-				OMX_IN OMX_BUFFERHEADERTYPE* buffer)
+                                OMX_IN OMX_HANDLETYPE         hComp,
+                                OMX_IN OMX_BUFFERHEADERTYPE* buffer)
 {
     OMX_ERRORTYPE eRet = OMX_ErrorNone;
 
-    DEBUG_PRINT("ETB:Buf:%p Len %u TS %lld numInBuf=%d\n", \
+    DEBUG_DETAIL("ETB:Buf:%p Len %u TS %lld numInBuf=%d\n", \
                 buffer, buffer->nFilledLen, buffer->nTimeStamp, (nNumInputBuf));
     if (m_state == OMX_StateInvalid)
     {
@@ -4076,7 +4076,7 @@
             meta_in.nFlags  |= OMX_BUFFERFLAG_EOS;
         }
         memcpy(data,&meta_in, meta_in.offsetVal);
-        DEBUG_PRINT("meta_in.nFlags = %d\n",meta_in.nFlags);
+        DEBUG_DETAIL("meta_in.nFlags = %d\n",meta_in.nFlags);
     } else {
         DEBUG_PRINT_ERROR("temp meta is null buf\n");
             return OMX_ErrorInsufficientResources;
@@ -4119,7 +4119,7 @@
 
     if (true == search_output_bufhdr(buffer))
     {
-          DEBUG_PRINT("\nBefore Read..m_drv_fd = %d,\n",m_drv_fd);
+          DEBUG_DETAIL("\nBefore Read..m_drv_fd = %d,\n",m_drv_fd);
           nReadbytes = read(m_drv_fd,buffer->pBuffer,output_buffer_size );
           DEBUG_DETAIL("FTBP->Al_len[%lu]buf[%p]size[%d]numOutBuf[%d]\n",\
                          buffer->nAllocLen,buffer->pBuffer,
@@ -4131,7 +4131,7 @@
              frame_done_cb((OMX_BUFFERHEADERTYPE *)buffer);
                   return OMX_ErrorNone;
       } else
-              DEBUG_PRINT("Read bytes %d\n",nReadbytes);
+              DEBUG_DETAIL("Read bytes %d\n",nReadbytes);
       // Buffer from Driver will have
       // 1 byte => Nr of frame field
       // (sizeof(ENC_META_OUT) * Nr of frame) bytes => meta_out->offset_to_frame
@@ -4139,7 +4139,7 @@
 
           meta_out = (ENC_META_OUT *)(buffer->pBuffer + sizeof(unsigned char));
           buffer->nTimeStamp = (((OMX_TICKS)meta_out->msw_ts << 32)+
-					meta_out->lsw_ts);
+                                        meta_out->lsw_ts);
           buffer->nFlags |= meta_out->nflags;
           buffer->nOffset = (OMX_U32)(meta_out->offset_to_frame +
                                     sizeof(unsigned char));
@@ -4147,9 +4147,9 @@
           ts += FRAMEDURATION;
           buffer->nTimeStamp = ts;
           nTimestamp = buffer->nTimeStamp;
-          DEBUG_PRINT("nflags %d frame_size %d offset_to_frame %d \
-		timestamp %lld\n", meta_out->nflags, meta_out->frame_size,
-		meta_out->offset_to_frame, buffer->nTimeStamp);
+          DEBUG_DETAIL("nflags %d frame_size %d offset_to_frame %d \
+                timestamp %lld\n", meta_out->nflags, meta_out->frame_size,
+                meta_out->offset_to_frame, buffer->nTimeStamp);
 
           if ((buffer->nFlags & OMX_BUFFERFLAG_EOS) == OMX_BUFFERFLAG_EOS )
           {
@@ -4168,7 +4168,7 @@
 
               return OMX_ErrorNone;
           }
-          DEBUG_PRINT("nState %d \n",nState );
+          DEBUG_DETAIL("nState %d \n",nState );
 
           pthread_mutex_lock(&m_state_lock);
           get_state(&m_cmp, &state);
@@ -4588,7 +4588,7 @@
 ========================================================================== */
 bool omx_amr_aenc::release_done(OMX_U32 param1)
 {
-    DEBUG_PRINT("Inside omx_amr_aenc::release_done");
+    DEBUG_DETAIL("Inside omx_amr_aenc::release_done");
     OMX_BOOL bRet = OMX_FALSE;
 
     if (param1 == OMX_ALL)
diff --git a/mm-audio/aenc-g711/qdsp6/Makefile.am b/mm-audio/aenc-g711/qdsp6/Makefile.am
index f5ccca8..02b0d57 100644
--- a/mm-audio/aenc-g711/qdsp6/Makefile.am
+++ b/mm-audio/aenc-g711/qdsp6/Makefile.am
@@ -8,7 +8,7 @@
             -D_ANDROID_ \
             -D_ENABLE_QC_MSG_LOG_ \
             -DVERBOSE \
-            -D_DEBUG \
+            -DNDEBUG \
             -DAUDIOV2 \
             -I inc \
             -I ${WORKSPACE}/hardware/qcom/media/mm-core/inc/
diff --git a/mm-audio/aenc-g711/qdsp6/inc/omx_g711_aenc.h b/mm-audio/aenc-g711/qdsp6/inc/omx_g711_aenc.h
index 4c8be66..0f415df 100644
--- a/mm-audio/aenc-g711/qdsp6/inc/omx_g711_aenc.h
+++ b/mm-audio/aenc-g711/qdsp6/inc/omx_g711_aenc.h
@@ -82,7 +82,7 @@
 
 
 #define PrintFrameHdr(i,bufHdr) \
-                           DEBUG_PRINT("i=%d OMX bufHdr[%p]buf[%p]size[%d]TS[%lld]nFlags[0x%x]\n",\
+                           DEBUG_DETAIL("i=%d OMX bufHdr[%p]buf[%p]size[%d]TS[%lld]nFlags[0x%x]\n",\
                            i,\
                            bufHdr,                                     \
                            ((OMX_BUFFERHEADERTYPE *)bufHdr)->pBuffer,   \
diff --git a/qahw/Android.mk b/qahw/Android.mk
index c7df9e3..0b782f0 100644
--- a/qahw/Android.mk
+++ b/qahw/Android.mk
@@ -27,6 +27,7 @@
 LOCAL_COPY_HEADERS      += inc/qahw_effect_api.h
 
 LOCAL_PRELINK_MODULE    := false
+LOCAL_VENDOR_MODULE     := true
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/qahw/Makefile.am b/qahw/Makefile.am
index 2f33c9f..1375157 100644
--- a/qahw/Makefile.am
+++ b/qahw/Makefile.am
@@ -18,4 +18,5 @@
 libqahwwrapper_la_CFLAGS += -Dstrlcpy=g_strlcpy $(GLIB_CFLAGS) -include glib.h
 libqahwwrapper_la_CFLAGS += -D__unused=__attribute__\(\(__unused__\)\)
 libqahwwrapper_la_CFLAGS += -Werror -Wall
+libqahwwrapper_la_CFLAGS += -DNDEBUG
 libqahwwrapper_la_LDFLAGS = -shared -avoid-version -llog -lcutils -lhardware $(GLIB_LIBS)
diff --git a/qahw/inc/qahw_effect_api.h b/qahw/inc/qahw_effect_api.h
index de53cd3..dbd61e2 100644
--- a/qahw/inc/qahw_effect_api.h
+++ b/qahw/inc/qahw_effect_api.h
@@ -31,8 +31,6 @@
 
 #include <system/audio.h>
 
-#include "qahw.h"
-
 __BEGIN_DECLS
 
 #define QAHW_EFFECT_API_VERSION_0_0 QAHW_MAKE_API_VERSION(0, 0)
diff --git a/qahw/src/qahw_effect.c b/qahw/src/qahw_effect.c
index cf7b3fd..2eff79f 100644
--- a/qahw/src/qahw_effect.c
+++ b/qahw/src/qahw_effect.c
@@ -38,6 +38,7 @@
 #include <hardware/audio_effect.h>
 #include <stdlib.h>
 
+#include "qahw.h"
 #include "qahw_effect_api.h"
 
 // The current effect API version.
diff --git a/qahw_api/Android.mk b/qahw_api/Android.mk
index ba402ba..fa4e6cb 100644
--- a/qahw_api/Android.mk
+++ b/qahw_api/Android.mk
@@ -34,6 +34,7 @@
 LOCAL_COPY_HEADERS      += inc/qahw_effect_visualizer.h
 
 LOCAL_PRELINK_MODULE    := false
+LOCAL_VENDOR_MODULE     := true
 
 include $(BUILD_SHARED_LIBRARY)
 
diff --git a/qahw_api/Makefile.am b/qahw_api/Makefile.am
index 13fe417..5892bb9 100644
--- a/qahw_api/Makefile.am
+++ b/qahw_api/Makefile.am
@@ -21,6 +21,7 @@
 libqahw_la_CPPFLAGS := $(AM_CPPFLAGS)
 libqahw_la_CPPFLAGS += -std=c++11 -DHAVE_PTHREADS -DHAVE_ANDROID_OS
 libqahw_la_CPPFLAGS += -DDEBUG_REFS_CALLSTACK_ENABLED=0
+libqahw_la_CPPFLAGS += -DNDEBUG
 libqahw_la_LDFLAGS   = -ltinyalsa -lhardware -lexpat -lcutils -llog -ldl -lbinder -shared -avoid-version -llog -lcutils -lpthread -lutils
 if QTI_AUDIO_SERVER_ENABLED
 AM_CPPFLAGS += -DQTI_AUDIO_SERVER_ENABLED
diff --git a/qahw_api/test/Android.mk b/qahw_api/test/Android.mk
index ec4e698..06e8a5a 100644
--- a/qahw_api/test/Android.mk
+++ b/qahw_api/test/Android.mk
@@ -20,10 +20,10 @@
     libutils \
     libcutils
 
-LOCAL_LDLIBS := -lpthread
 LOCAL_32_BIT_ONLY := true
 
 LOCAL_C_INCLUDES += $(hal-play-inc)
+LOCAL_VENDOR_MODULE := true
 
 include $(BUILD_EXECUTABLE)
 
@@ -43,4 +43,6 @@
 hal-rec-inc     = $(TARGET_OUT_HEADERS)/mm-audio/qahw_api/inc
 
 LOCAL_C_INCLUDES += $(hal-rec-inc)
+LOCAL_VENDOR_MODULE := true
+
 include $(BUILD_EXECUTABLE)
diff --git a/qahw_api/test/qahw_effect_test.c b/qahw_api/test/qahw_effect_test.c
index bc249f3..9ea362f 100644
--- a/qahw_api/test/qahw_effect_test.c
+++ b/qahw_api/test/qahw_effect_test.c
@@ -34,6 +34,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+#include <signal.h>
 
 #include "qahw_api.h"
 #include "qahw_defs.h"
@@ -111,6 +112,12 @@
 #define NUM_EQ_BANDS 5
 const uint16_t qahw_equalizer_band_freqs[NUM_EQ_BANDS] = {60, 230, 910, 3600, 14000}; /* frequencies in HZ */
 
+/* Handler to handle input command_thread_func signal */
+void stop_effect_command_thread_handler(int signal __unused)
+{
+   pthread_exit(NULL);
+}
+
 /* THREAD BODY OF BASSBOOST */
 void *bassboost_thread_func(void* data) {
     thread_data_t            *thr_ctxt = (thread_data_t *)data;
@@ -489,6 +496,12 @@
     qahw_effect_param_t *param = (qahw_effect_param_t *)buf32;
     qahw_effect_param_t *param_2 = (qahw_effect_param_t *)buf32_2;
 
+    /* Register the SIGUSR1 to close this thread properly
+       as it is waiting for input in while loop */
+    if (signal(SIGUSR1, stop_effect_command_thread_handler) == SIG_ERR) {
+        fprintf(stderr, "Failed to register SIGUSR1:%d\n",errno);
+    }
+
     while(!thr_ctxt->exit) {
         if (fgets(cmd_str, sizeof(cmd_str), stdin) == NULL) {
             fprintf(stderr, "read error\n");
diff --git a/qahw_api/test/qahw_multi_record_test.c b/qahw_api/test/qahw_multi_record_test.c
index d618101..2e0a396 100644
--- a/qahw_api/test/qahw_multi_record_test.c
+++ b/qahw_api/test/qahw_multi_record_test.c
@@ -588,7 +588,7 @@
     printf("                                               For mono channel 16kHz rate for 30seconds\n\n");
 }
 
-static void qti_audio_server_death_notify_cb(void *ctxt) {
+static void qti_audio_server_death_notify_cb(void *ctxt __unused) {
     fprintf(log_file, "qas died\n");
     fprintf(stderr, "qas died\n");
     stop_record = true;
@@ -769,7 +769,7 @@
     /* set global setparams entered by user.
      * Also other global setparams can be concatenated if required.
      */
-    if (params[0].kvpairs != NULL) {
+    if (params[0].kvpairs[0] != 0) {
         size_t len;
         len = strcspn(params[0].kvpairs, ",");
         while (len < strlen(params[0].kvpairs)) {
diff --git a/qahw_api/test/qahw_playback_test.c b/qahw_api/test/qahw_playback_test.c
index fceff8b..2469b3c 100644
--- a/qahw_api/test/qahw_playback_test.c
+++ b/qahw_api/test/qahw_playback_test.c
@@ -854,10 +854,12 @@
         // destory effect command thread
         params->cmd_data.exit = true;
         usleep(100000);  // give a chance for thread to exit gracefully
-        rc = pthread_cancel(params->cmd_data.cmd_thread);
+
+        //Send signal for input command_thread_func to stop
+        rc = pthread_kill(params->cmd_data.cmd_thread, SIGUSR1);
         if (rc != 0) {
-            fprintf(log_file, "Fail to cancel thread!\n");
-            fprintf(stderr, "Fail to cancel thread!\n");
+            fprintf(log_file, "Fail to kill effect command thread!\n");
+            fprintf(stderr, "Fail to kill effect command thread!\n");
         }
         rc = pthread_join(params->cmd_data.cmd_thread, NULL);
         if (rc < 0) {
@@ -1197,7 +1199,7 @@
 int tigger_event(qahw_stream_handle_t* out_handle)
 {
     qahw_param_payload payload;
-    struct event_data event_payload = {0};
+    struct event_data event_payload = {0, 0, 0, 0, 0, 0, 0};
     int ret = 0;
 
     event_payload.num_events = 1;
diff --git a/qahw_api/test/qahw_playback_test.h b/qahw_api/test/qahw_playback_test.h
index 3ec8f25..b643c1d 100644
--- a/qahw_api/test/qahw_playback_test.h
+++ b/qahw_api/test/qahw_playback_test.h
@@ -159,8 +159,12 @@
 #define is_qap_session_active(argc, argv, kvp_string)                    (0)
 #define get_play_list(fp, stream_param, num_of_streams, kvp_str)         (0)
 #define check_for_playlist(kvp_string)                                   (0)
-#define start_playback_through_qap(kvp_string, num_of_streams,\
-                                         qap_out_hal_handle_t)           (0)
+inline int start_playback_through_qap(char * kvp_string __unused,
+                                      int num_of_streams __unused,
+                                      qahw_module_handle_t *qap_out_hal_handle_t __unused)
+{
+    return 0;
+}
 #define start_playback_through_qap_playlist(cmd_kvp_str, num_of_streams,\
                    kvp_string, stream_param, qap_wrapper_session_active,\
                    qap_out_hal_handle_t)                                 (0)