hal: passthru: Fix to avoid mute in DDP passthru

-Mute ovserved on HDMI sink while rendering
high bitrate DDP content
-Offload buffer size is just 2k,
increasing it to handle high bit rate content
-QAF: Session close is blocked if pcm stream open is failed
--This is fixed by cleaning up the pcm stream

Change-Id: Ibc0efd99194ba4039921029f52f580dc9db79503
diff --git a/hal/audio_extn/passthru.c b/hal/audio_extn/passthru.c
index 8acffda..1ee0008 100644
--- a/hal/audio_extn/passthru.c
+++ b/hal/audio_extn/passthru.c
@@ -69,6 +69,8 @@
 
 #define MIN_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (2 * 1024)
 
+#define DDP_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE (10 * 1024)
+
 static const audio_format_t audio_passthru_formats[] = {
     AUDIO_FORMAT_AC3,
     AUDIO_FORMAT_E_AC3,
@@ -490,8 +492,14 @@
                (info->format == AUDIO_FORMAT_DTS_HD)) {
         fragment_size = MAX_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE;
         goto done;
+    } else if (info->format == AUDIO_FORMAT_E_AC3) {
+        fragment_size = DDP_COMPRESS_PASSTHROUGH_FRAGMENT_SIZE;
+        if(property_get("audio.ddp.buffer.size.kb", value, "") &&
+                atoi(value)) {
+            fragment_size = atoi(value) * 1024;
+        }
+        goto done;
     }
-
 done:
     return fragment_size;
 
diff --git a/hal/audio_extn/qaf.c b/hal/audio_extn/qaf.c
index 9c57b2c..ca83b1d 100644
--- a/hal/audio_extn/qaf.c
+++ b/hal/audio_extn/qaf.c
@@ -2007,7 +2007,11 @@
                                                 input_config,
                                                 devices,
                                                 AUDIO_STREAM_SYSTEM_TONE);
-        qaf_mod->stream_in[QAF_IN_PCM] = out;
+        if (status == 0) {
+            qaf_mod->stream_in[QAF_IN_PCM] = out;
+        } else {
+            ERROR_MSG("System tone stream open failed with QAF module !!!");
+        }
     } else if ((flags & AUDIO_OUTPUT_FLAG_MAIN) && (flags & AUDIO_OUTPUT_FLAG_ASSOCIATED)) {
         if (is_main_active(qaf_mod) || is_dual_main_active(qaf_mod)) {
             ERROR_MSG("Dual Main or Main already active. So, Cannot open main and associated stream");