codec2: fix C2SoftMp3Dec handle first empty eos frame

Test: MtsHidlC2V1_0TargetAudioDecTest -I software \
-C c2.android.mp3.decoder -P /sdcard/res/

Bug: 110549953
Change-Id: Ie196ae36b1024ede19bbe9bd9d1d3d9ba6f0279e
diff --git a/media/codecs/mp3/C2SoftMp3Dec.cpp b/media/codecs/mp3/C2SoftMp3Dec.cpp
index 72908dc..48de625 100644
--- a/media/codecs/mp3/C2SoftMp3Dec.cpp
+++ b/media/codecs/mp3/C2SoftMp3Dec.cpp
@@ -135,6 +135,7 @@
 }
 
 void C2SoftMP3::onRelease() {
+    mGaplessBytes = false;
     if (mDecoderBuf) {
         free(mDecoderBuf);
         mDecoderBuf = nullptr;
@@ -159,6 +160,7 @@
     pvmp3_InitDecoder(mConfig, mDecoderBuf);
 
     mIsFirst = true;
+    mGaplessBytes = false;
     mSignalledError = false;
     mSignalledOutputEos = false;
     mAnchorTimeStamp = 0;
@@ -355,7 +357,7 @@
         }
     }
 
-    if (inSize == 0 && !eos) {
+    if (inSize == 0 && (!mGaplessBytes || !eos)) {
         work->worklets.front()->output.flags = work->input.flags;
         work->worklets.front()->output.buffers.clear();
         work->worklets.front()->output.ordinal = work->input.ordinal;
@@ -466,6 +468,7 @@
     }
     if (mIsFirst) {
         mIsFirst = false;
+        mGaplessBytes = true;
         // The decoder delay is 529 samples, so trim that many samples off
         // the start of the first output buffer. This essentially makes this
         // decoder have zero delay, which the rest of the pipeline assumes.
@@ -482,6 +485,7 @@
                 return;
              }
             ALOGV("Adding 529 samples at end");
+            mGaplessBytes = false;
             outSize += kPVMP3DecoderDelay * numChannels * sizeof(int16_t);
         }
     }
diff --git a/media/codecs/mp3/C2SoftMp3Dec.h b/media/codecs/mp3/C2SoftMp3Dec.h
index 0f4b4f6..402bdc4 100644
--- a/media/codecs/mp3/C2SoftMp3Dec.h
+++ b/media/codecs/mp3/C2SoftMp3Dec.h
@@ -62,6 +62,7 @@
     bool mIsFirst;
     bool mSignalledError;
     bool mSignalledOutputEos;
+    bool mGaplessBytes;
     uint64_t mAnchorTimeStamp;
     uint64_t mProcessedSamples;