am 44577d1f: Fix a bunch of AAC encoder issues - Fixed a timeout issue when the close is sent but the component thread does not exit - Fixed a race condition waiting for stop to complete - Don\'t return error from OMX_GetState()
diff --git a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c
index 885a9dd..655fd25 100644
--- a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c
+++ b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEnc_CompThread.c
@@ -231,10 +231,11 @@
                     pComponentPrivate->bPreempted = 0;
                 }
 
-            pComponentPrivate->bLoadedCommandPending = OMX_FALSE;
+                pComponentPrivate->bLoadedCommandPending = OMX_FALSE;
+                goto EXIT;
             }
 
-        }  
+        }
     }
 
 EXIT:
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 e4d7b8d..85f79c7 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
@@ -951,18 +951,16 @@
 
                         pComponentPrivate->bIsStopping = 1;
 
-						if (pComponentPrivate->codecStop_waitingsignal == 0){ 
-							pthread_mutex_lock(&pComponentPrivate->codecStop_mutex); 	
-						}
                         eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,
                                                       MMCodecControlStop,(void *)pArgs);
 
-	                    if (pComponentPrivate->codecStop_waitingsignal == 0){
-	                        pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex);
-	                        pComponentPrivate->codecStop_waitingsignal = 0;
-	                        pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);
-	                    }
-					
+                        pthread_mutex_lock(&pComponentPrivate->codecStop_mutex);
+                        while (pComponentPrivate->codecStop_waitingsignal == 0){
+                            pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex);
+                        }
+                        pComponentPrivate->codecStop_waitingsignal = 0;
+                        pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);
+
                         if(eError != OMX_ErrorNone) 
                         {
                             OMX_ERROR4(pComponentPrivate->dbg, "%d: Error Occurred in Codec Stop..\n",__LINE__);
@@ -1467,18 +1465,15 @@
                     pComponentPrivate->bNoIdleOnStop = OMX_TRUE;
                     OMX_PRINT2(pComponentPrivate->dbg, "AACENC: About to stop socket node line %d\n",__LINE__);
 
-                        pComponentPrivate->bIsStopping = 1;
-					if (pComponentPrivate->codecStop_waitingsignal == 0){ 
-						pthread_mutex_lock(&pComponentPrivate->codecStop_mutex); 	
-					}
+                    pComponentPrivate->bIsStopping = 1;
                     eError = LCML_ControlCodec(((LCML_DSP_INTERFACE*)pLcmlHandle)->pCodecinterfacehandle,
                                                   MMCodecControlStop,(void *)pArgs);
-
-                    if (pComponentPrivate->codecStop_waitingsignal == 0){
+                    pthread_mutex_lock(&pComponentPrivate->codecStop_mutex);
+                    while (pComponentPrivate->codecStop_waitingsignal == 0){
                         pthread_cond_wait(&pComponentPrivate->codecStop_threshold, &pComponentPrivate->codecStop_mutex);
-                        pComponentPrivate->codecStop_waitingsignal = 0;
-                        pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);
                     }
+                    pComponentPrivate->codecStop_waitingsignal = 0;
+                    pthread_mutex_unlock(&pComponentPrivate->codecStop_mutex);
                 }
             }
         }
@@ -2625,7 +2620,7 @@
 
         pthread_mutex_lock(&pComponentPrivate_CC->codecStop_mutex);
         if(pComponentPrivate_CC->codecStop_waitingsignal == 0){
-            pComponentPrivate_CC->codecStop_waitingsignal = 1;             
+            pComponentPrivate_CC->codecStop_waitingsignal = 1;
             pthread_cond_signal(&pComponentPrivate_CC->codecStop_threshold);
             OMX_PRINT2(pComponentPrivate_CC->dbg, "stop ack. received. stop waiting for sending disable command completed\n");
         }
diff --git a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c
index ca41930..845c565 100644
--- a/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c
+++ b/omx/audio/src/openmax_il/aac_enc/src/OMX_AacEncoder.c
@@ -1458,7 +1458,8 @@
            else if(ret == ETIMEDOUT) {
               /* Unlock mutex in case of timeout */
               pthread_mutex_unlock(&pComponentPrivate->mutexStateChangeRequest);
-              return OMX_ErrorTimeout;
+              *pState = OMX_StateInvalid;
+              return OMX_ErrorNone;
            }
         }
      }