C2SoftXaacDec: Handle error cases when decoder fails to initialize

When decoder fails to initialize, it doesn't consume any bytes in
subsequent process call. Avoid this by returning an error when decoder
is not initialized before first process call.

Bug: 112194305
Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases\
 -t android.security.cts.StagefrightTest#testStagefright_c_2016_2428

Change-Id: I725c14a7634bab9355dbe743425919eea814f865
diff --git a/media/codecs/xaac/C2SoftXaacDec.cpp b/media/codecs/xaac/C2SoftXaacDec.cpp
index 69b70cf..ba856d1 100644
--- a/media/codecs/xaac/C2SoftXaacDec.cpp
+++ b/media/codecs/xaac/C2SoftXaacDec.cpp
@@ -518,7 +518,6 @@
                 work->result = C2_CORRUPTED;
                 return;
             }
-            mIsCodecConfigFlushRequired = true;
 
             if ((mSampFreq != prevSampleRate) ||
                 (mNumChannels != prevNumChannels)) {
@@ -549,10 +548,14 @@
         signed int bytesConsumed = 0;
         IA_ERRORCODE errorCode = IA_NO_ERROR;
         if (mIsCodecInitialized) {
+            mIsCodecConfigFlushRequired = true;
             errorCode = decodeXAACStream(inBuffer, inBufferLength,
                                          &bytesConsumed, &mNumOutBytes);
-        } else {
+        } else if (!mIsCodecConfigFlushRequired) {
             ALOGW("Assumption that first frame after header initializes decoder Failed!");
+            mSignalledError = true;
+            work->result = C2_CORRUPTED;
+            return;
         }
         size -= bytesConsumed;
         offset += bytesConsumed;