Send event for omx idle state transition failures

Return an error event in the case when the encoder components are unable to
transition to the idle state.

Originally from: https://partner.source.android.com/g/#change,1403
diff --git a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c
index fdb89ad..c309e58 100644
--- a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c
+++ b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_Utils.c
@@ -888,6 +888,15 @@
                         if(eError != OMX_ErrorNone) 
                         {
                             OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error returned from LCML_Init()\n",__LINE__);
+                            /* send an event to client */
+                            /* client should unload the component if the codec is not able to load */
+                            eError = OMX_ErrorInvalidState;
+                            pComponentPrivate->cbInfo.EventHandler (pHandle,
+                                    pHandle->pApplicationPrivate,
+                                    OMX_EventError,
+                                    eError,
+                                    OMX_TI_ErrorSevere,
+                                    NULL);
                             goto EXIT;
                         }
 
diff --git a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c
index 74f4522..b2c96c5 100644
--- a/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c
+++ b/omx/audio/src/openmax_il/nbamr_enc/src/OMX_AmrEnc_Utils.c
@@ -876,6 +876,15 @@
 
                 if(eError != OMX_ErrorNone) {
                     OMX_ERROR4(pComponentPrivate->dbg, "%d :: Error returned from LCML_Init()\n",__LINE__);
+                    /* send an event to client */
+                    /* client should unload the component if the codec is not able to load */
+                    eError = OMX_ErrorInvalidState;
+                    pComponentPrivate->cbInfo.EventHandler (pHandle,
+                                                            pHandle->pApplicationPrivate,
+                                                            OMX_EventError,
+                                                            eError,
+                                                            OMX_TI_ErrorSevere,
+                                                            NULL);
                     goto EXIT;
                 }
 
diff --git a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c
index 9faaca8..d8a984d 100644
--- a/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c
+++ b/omx/audio/src/openmax_il/wbamr_enc/src/OMX_WbAmrEnc_Utils.c
@@ -894,8 +894,16 @@
 #endif
 
                     if(eError != OMX_ErrorNone) {
-                        OMX_ERROR4(pComponentPrivate->dbg,
-                                   "Error returned from LCML_InitMMCodecEx\n");
+                        OMX_ERROR4(pComponentPrivate->dbg ,"Error returned from LCML_InitMMCodecEx\n");
+                        /* send an event to client */
+                        /* client should unload the component if the codec is not able to load */
+                        eError = OMX_ErrorInvalidState;
+                        pComponentPrivate->cbInfo.EventHandler (pHandle,
+                                                            pHandle->pApplicationPrivate,
+                                                            OMX_EventError,
+                                                            eError,
+                                                            OMX_TI_ErrorSevere,
+                                                            NULL);
                         goto EXIT;
                     }
 #ifdef RESOURCE_MANAGER_ENABLED
diff --git a/omx/video/src/openmax_il/video_encode/src/OMX_VideoEnc_Utils.c b/omx/video/src/openmax_il/video_encode/src/OMX_VideoEnc_Utils.c
index b13d8ad..343453a 100644
--- a/omx/video/src/openmax_il/video_encode/src/OMX_VideoEnc_Utils.c
+++ b/omx/video/src/openmax_il/video_encode/src/OMX_VideoEnc_Utils.c
@@ -3332,7 +3332,7 @@
         OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...\n");
         /*TODO: Validate eError from LCML_InitMMCodec for ResourceExhaustionTest */
         pComponentPrivate->bErrorLcmlHandle = OMX_TRUE;
-        OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorInsufficientResources);
+        OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorInvalidState);
     }
     pComponentPrivate->bCodecLoaded = OMX_TRUE;
     VIDENC_FREE(pCreatePhaseArgs, pMemoryListHead,
@@ -3680,7 +3680,7 @@
         OMX_PRDSP4(pComponentPrivate->dbg, "LCML_InitMMCodec Failed!...\n");  
         /*TODO: Validate eError from LCML_InitMMCodec for ResourceExhaustionTest */
         pComponentPrivate->bErrorLcmlHandle = OMX_TRUE;
-        OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorInsufficientResources);
+        OMX_CONF_SET_ERROR_BAIL(eError, OMX_ErrorInvalidState);
     }
     pComponentPrivate->bCodecLoaded = OMX_TRUE;
     VIDENC_FREE(pCreatePhaseArgs, pMemoryListHead,