C2VDAComponent: handle empty CSD work

In MediaCodec, CSD buffers are allowed to be empty (size=0), as for CCodec
there is no input buffer sent along the work. We need to handle empty CSD
buffer case for C2VDAComponent and tell apart from EOS work which also contains
no input buffer.

Bug: 80402878
Test: android.media.cts.AdaptivePlaybackTest#testH264_adaptiveEarlyEos for
codec2.0 on eve-arcnext

Change-Id: I19bf54d9bbbda89713660e0e73c3f5a10f93e106
diff --git a/C2VDAComponent.cpp b/C2VDAComponent.cpp
index 325bf6b..78e5814 100644
--- a/C2VDAComponent.cpp
+++ b/C2VDAComponent.cpp
@@ -307,9 +307,12 @@
 
     CHECK_LE(work->input.buffers.size(), 1u);
     if (work->input.buffers.empty()) {
-        // Client may queue an EOS work with no input buffer, otherwise every work must have one
-        // input buffer.
-        CHECK(drainMode != NO_DRAIN);
+        // Client may queue a work with no input buffer for either it's EOS or empty CSD, otherwise
+        // every work must have one input buffer.
+        CHECK(drainMode != NO_DRAIN || work->input.flags & C2FrameData::FLAG_CODEC_CONFIG);
+        // Emplace a nullptr to unify the check for work done.
+        ALOGV("Got a work with no input buffer! Emplace a nullptr inside.");
+        work->input.buffers.emplace_back(nullptr);
     } else {
         // If input.buffers is not empty, the buffer should have meaningful content inside.
         C2ConstLinearBlock linearBlock = work->input.buffers.front()->data().linearBlocks().front();
@@ -1141,8 +1144,8 @@
 }
 
 bool C2VDAComponent::isWorkDone(const C2Work* work) const {
-    if (work->input.buffers.empty()) {
-        // This is EOS work with no input buffer and should be processed by reportEOSWork().
+    if (work->input.flags & C2FrameData::FLAG_END_OF_STREAM) {
+        // This is EOS work and should be processed by reportEOSWork().
         return false;
     }
     if (work->input.buffers.front()) {