codec2: VTS add support for Empty EOS in AudioDectest

Test: VtsHidlC2V1_0TargetAudioDecTest -I software -P /sdcard/res/ -C c2.android.mp3.decoder
Bug: 127691941

Change-Id: I15ef8157cd09ab4522320e0e717f3e835eb1815d
diff --git a/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp b/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp
index 443faab..89947d4 100644
--- a/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp
+++ b/media/codec2/hidl/1.0/vts/functional/audio/VtsHidlC2V1_0TargetAudioDecTest.cpp
@@ -506,15 +506,17 @@
     ASSERT_EQ(mComponent->stop(), C2_OK);
 }
 
-class Codec2AudioDecDecodeTest : public Codec2AudioDecHidlTest,
-                                 public ::testing::WithParamInterface<int32_t> {
+class Codec2AudioDecDecodeTest
+    : public Codec2AudioDecHidlTest,
+      public ::testing::WithParamInterface<std::pair<int32_t, bool>> {
 };
 
 TEST_P(Codec2AudioDecDecodeTest, DecodeTest) {
     description("Decodes input file");
     if (mDisableTest) return;
 
-    uint32_t streamIndex = GetParam();
+    uint32_t streamIndex = GetParam().first;
+    bool signalEOS = GetParam().second;
     mTimestampDevTest = true;
     char mURL[512], info[512];
     std::ifstream eleStream, eleInfo;
@@ -566,16 +568,27 @@
     ASSERT_EQ(eleStream.is_open(), true);
     ASSERT_NO_FATAL_FAILURE(decodeNFrames(
         mComponent, mQueueLock, mQueueCondition, mWorkQueue, mFlushedIndices,
-        mLinearPool, eleStream, &Info, 0, (int)Info.size()));
+        mLinearPool, eleStream, &Info, 0, (int)Info.size(), signalEOS));
+
+    // If EOS is not sent, sending empty input with EOS flag
+    size_t infoSize = Info.size();
+    if (!signalEOS) {
+        ASSERT_NO_FATAL_FAILURE(
+            waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue, 1));
+        ASSERT_NO_FATAL_FAILURE(
+            testInputBuffer(mComponent, mQueueLock, mWorkQueue,
+                            C2FrameData::FLAG_END_OF_STREAM, false));
+        infoSize += 1;
+    }
     // blocking call to ensures application to Wait till all the inputs are
     // consumed
     ASSERT_NO_FATAL_FAILURE(
         waitOnInputConsumption(mQueueLock, mQueueCondition, mWorkQueue));
     eleStream.close();
-    if (mFramesReceived != Info.size()) {
+    if (mFramesReceived != infoSize) {
         ALOGE("Input buffer count and Output buffer count mismatch");
         ALOGE("framesReceived : %d inputFrames : %zu", mFramesReceived,
-              Info.size());
+              infoSize);
         ASSERT_TRUE(false);
     }
     ASSERT_EQ(mEos, true);
@@ -607,9 +620,12 @@
     }
     ASSERT_EQ(mComponent->stop(), C2_OK);
 }
-
-INSTANTIATE_TEST_CASE_P(StreamIndexes, Codec2AudioDecDecodeTest,
-                        ::testing::Values(0, 1));
+// DecodeTest with StreamIndex and EOS / No EOS
+INSTANTIATE_TEST_CASE_P(StreamIndexAndEOS, Codec2AudioDecDecodeTest,
+                        ::testing::Values(std::make_pair(0, false),
+                                          std::make_pair(0, true),
+                                          std::make_pair(1, false),
+                                          std::make_pair(1, true)));
 
 // thumbnail test
 TEST_F(Codec2AudioDecHidlTest, ThumbnailTest) {