Merge 5e6ec733 from gingerbread-plus-aosp

Change-Id: I85522668d103b66e9933416bb015ce4176d3842e
diff --git a/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h b/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h
index d4ddeed..6b51fd7 100644
--- a/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h
+++ b/omx/audio/src/openmax_il/aac_dec/inc/OMX_AacDec_Utils.h
@@ -537,6 +537,10 @@
     IUALG_CMD_USERCMDSTART_AACDEC  = 100
 }IUALG_Cmd_AAC_DEC;
 
+typedef enum{
+  IAAC_WARN_DATA_CORRUPT = 0x0804
+}IAAC_WARN_MSG;
+
 #ifdef UNDER_CE
 #ifndef _OMX_EVENT_
 #define _OMX_EVENT_
diff --git a/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c b/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c
index 02c1911..f8fc446 100644
--- a/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c
+++ b/omx/audio/src/openmax_il/aac_dec/src/OMX_AacDec_Utils.c
@@ -3834,6 +3834,9 @@
             }
 #endif
             break;
+        case IAAC_WARN_DATA_CORRUPT:
+            OMX_ERROR4(pComponentPrivate->dbg,  "LCML_Callback: Algorithm error, stream corrupt\n");
+            break;
         case IUALG_WARN_CONCEALED:
         case IUALG_WARN_UNDERFLOW:
         case IUALG_WARN_OVERFLOW:
diff --git a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c
index a7fc638..2d825e2 100644
--- a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c
+++ b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEncoder.c
@@ -1126,51 +1126,53 @@
                     memcpy(((AMRENC_COMPONENT_PRIVATE*)
                             pHandle->pComponentPrivate)->pcmParams, pCompAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
                 } else if (pCompAmrParam->nPortIndex == 1) { /* 1 means Output port */
+                    if (((AMRENC_COMPONENT_PRIVATE *) pHandle->pComponentPrivate)->amrParams == NULL) {
+                        eError = OMX_ErrorBadParameter;
+                        goto EXIT;
+                    }
+
+                    memcpy(((AMRENC_COMPONENT_PRIVATE *)
+                            pHandle->pComponentPrivate)->amrParams, pCompAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
+
                     switch (pCompAmrParam->eAMRBandMode)
                     {
                              case OMX_AUDIO_AMRBandModeNB7:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR122;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR122;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR122 \n",__LINE__);
                                   break;
                              case OMX_AUDIO_AMRBandModeNB6:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR102;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR102;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR102 \n",__LINE__);
                                   break;
                              case OMX_AUDIO_AMRBandModeNB5:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR795;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR795;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR795 \n",__LINE__);
                                   break;
                              case OMX_AUDIO_AMRBandModeNB4:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR74;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR74;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR74 \n",__LINE__);
                                   break;
                              case OMX_AUDIO_AMRBandModeNB3:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR67;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR67;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR67 \n",__LINE__);
                                   break;
                              case OMX_AUDIO_AMRBandModeNB2:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR59;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR59;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR59 \n",__LINE__);
                                   break;
                              case OMX_AUDIO_AMRBandModeNB1:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR515;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR515;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR515 \n",__LINE__);
                                   break;
                              case OMX_AUDIO_AMRBandModeNB0:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_475;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_475;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode = SN_AUDIO_BR475 \n",__LINE__);
                                   break;
                              default:
-                                  pCompAmrParam->eAMRBandMode = SN_AUDIO_BR122;
+                                  pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR122;
                                   OMX_PRDSP2(pComponentPrivate->dbg, "%d :: SetParameter OMX_IndexParamAudioAmr:: pCompAmrParam->eAMRBandMode =DEFAULT!! SN_AUDIO_BR122 \n",__LINE__);
                                   break;
                     }
-		    if (((AMRENC_COMPONENT_PRIVATE *) pHandle->pComponentPrivate)->amrParams == NULL) {
-                        eError = OMX_ErrorBadParameter;
-			goto EXIT;
-		    }
-                    memcpy(((AMRENC_COMPONENT_PRIVATE *)
-                            pHandle->pComponentPrivate)->amrParams, pCompAmrParam, sizeof(OMX_AUDIO_PARAM_AMRTYPE));
                     if (pCompAmrParam->eAMRFrameFormat == OMX_AUDIO_AMRFrameFormatConformance) {
                         pComponentPrivate->frameMode = NBAMRENC_FORMATCONFORMANCE;
                     }
diff --git a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEncoder.c b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEncoder.c
index 7fc1b8d..797dd64 100644
--- a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEncoder.c
+++ b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEncoder.c
@@ -167,11 +167,12 @@
 static OMX_ERRORTYPE ComponentRoleEnum(OMX_IN OMX_HANDLETYPE hComponent,
                                        OMX_OUT OMX_U8 *cRole,
                                        OMX_IN OMX_U32 nIndex);
-
+#ifdef DSP_RENDERING_ON
 /* interface with audio manager*/
 #define FIFO1 "/dev/fifo.1"
 #define FIFO2 "/dev/fifo.2"
 #define PERMS 0666
+#endif
 
 /*-------------------------------------------------------------------*/
 /**
@@ -507,7 +508,7 @@
 #endif
 
 #ifndef UNDER_CE
-
+#ifdef DSP_RENDERING_ON
     if ((pComponentPrivate->fdwrite = open(FIFO1, O_WRONLY)) < 0) {
         OMX_PRCOMM4(pComponentPrivate->dbg, "Failure to open Write pipe");
     }
@@ -515,7 +516,7 @@
     if ((pComponentPrivate->fdread = open(FIFO2, O_RDONLY)) < 0) {
         OMX_PRCOMM4(pComponentPrivate->dbg, "Failure to open Read pipe");
     }
-
+#endif
 #endif
 
   pComponentPrivate->nPendingStateChangeRequests = 0;
@@ -1106,48 +1107,49 @@
                        pCompAmrParam,
                        sizeof(OMX_AUDIO_PARAM_AMRTYPE));
             } else if (pCompAmrParam->nPortIndex == 1) { /* 1 means Output port */
-                switch (pCompAmrParam->eAMRBandMode) {
-                    case OMX_AUDIO_AMRBandModeWB0:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR660;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB1:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR885;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB2:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR1265;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB3:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR1425;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB4:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR1585;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB5:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR1825;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB6:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR1985;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB7:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR2305;
-                        break;
-                    case OMX_AUDIO_AMRBandModeWB8:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR2385;
-                        break;
-                    default:
-                        pCompAmrParam->eAMRBandMode = SN_AUDIO_BR660;
-                        break;
+                if (((WBAMRENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->amrParams == NULL) {
+                    eError = OMX_ErrorBadParameter;
+                    break;
                 }
-
-	        if (((WBAMRENC_COMPONENT_PRIVATE *)pHandle->pComponentPrivate)->amrParams == NULL) {
-	            eError = OMX_ErrorBadParameter;
-                    break; 
-	        }
                 memcpy(((WBAMRENC_COMPONENT_PRIVATE *)
                         pHandle->pComponentPrivate)->amrParams,
                        pCompAmrParam,
                        sizeof(OMX_AUDIO_PARAM_AMRTYPE));
 
+
+                switch (pCompAmrParam->eAMRBandMode) {
+                    case OMX_AUDIO_AMRBandModeWB0:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR660;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB1:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR885;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB2:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR1265;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB3:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR1425;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB4:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR1585;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB5:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR1825;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB6:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR1985;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB7:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR2305;
+                        break;
+                    case OMX_AUDIO_AMRBandModeWB8:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR2385;
+                        break;
+                    default:
+                        pComponentPrivate->amrParams->eAMRBandMode = SN_AUDIO_BR660;
+                        break;
+                }
+
                 if (pCompAmrParam->eAMRFrameFormat == OMX_AUDIO_AMRFrameFormatConformance) {
                     pComponentPrivate->frameMode = WBAMRENC_FORMATCONFORMANCE;
                 } else if (pCompAmrParam->eAMRFrameFormat == OMX_AUDIO_AMRFrameFormatFSF) {
diff --git a/omx/system/src/openmax_il/lcml/src/LCML_DspCodec.c b/omx/system/src/openmax_il/lcml/src/LCML_DspCodec.c
index 7a25564..c74082a 100644
--- a/omx/system/src/openmax_il/lcml/src/LCML_DspCodec.c
+++ b/omx/system/src/openmax_il/lcml/src/LCML_DspCodec.c
@@ -1853,13 +1853,21 @@
                         {
                             char *tmp2 = NULL;
 
-                            status = DSPProcessor_InvalidateMemory(hDSPInterface->dspCodec->hProc, tmpDspStructAddress, sizeof(TArmDspCommunicationStruct));
-                            if(DSP_FAILED(status))
+                            status = DSPProcessor_InvalidateMemory(hDSPInterface->dspCodec->hProc,
+                                            tmpDspStructAddress, sizeof(TArmDspCommunicationStruct));
+                            if (DSP_FAILED(status)) {
                                 LOGE("Invalidate for communication structure failed. status = 0x%x\n", status);
+                            }
 
-                            status = DSPProcessor_InvalidateMemory(hDSPInterface->dspCodec->hProc, tmpDspStructAddress->iArmParamArg, tmpDspStructAddress->iParamSize);
-                            if(DSP_FAILED(status))
-                                LOGE("Invalidate for arm parameter arguments failed. status = 0x%x\n", status);
+                            // Only invalidate the memory when the pointer points to some valid memory region
+                            // otherwise, we will get logging spam
+                            if (tmpDspStructAddress->iArmParamArg != NULL && tmpDspStructAddress->iParamSize > 0) {
+                                status = DSPProcessor_InvalidateMemory(hDSPInterface->dspCodec->hProc,
+                                                tmpDspStructAddress->iArmParamArg, tmpDspStructAddress->iParamSize);
+                                if (DSP_FAILED(status)) {
+                                    LOGE("Invalidate for arm parameter arguments failed. status = 0x%x\n", status);
+                                }
+                            }
 
                             event = EMMCodecBufferProcessed;
                             args[0] = (void *) bufType;