Merge "CCodecBufferChannel: decrease balance for discarded work as well" into main am: 7843f5dafe

Original change: https://android-review.googlesource.com/c/platform/frameworks/av/+/3276973

Change-Id: I3c8f1b9042e380afb0acc9621497de73c965a6f1
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/media/codec2/sfplugin/CCodecBufferChannel.cpp b/media/codec2/sfplugin/CCodecBufferChannel.cpp
index 1cbfc75..3ef2f84 100644
--- a/media/codec2/sfplugin/CCodecBufferChannel.cpp
+++ b/media/codec2/sfplugin/CCodecBufferChannel.cpp
@@ -2628,8 +2628,6 @@
         switch (action) {
         case OutputBuffers::SKIP:
             return;
-        case OutputBuffers::DISCARD:
-            break;
         case OutputBuffers::NOTIFY_CLIENT:
         {
             // TRICKY: we want popped buffers reported in order, so sending
@@ -2656,13 +2654,16 @@
                     outBuffer->meta()->setObject("accessUnitInfo", obj);
                 }
             }
+            mCallback->onOutputBufferAvailable(index, outBuffer);
+            [[fallthrough]];
+        }
+        case OutputBuffers::DISCARD: {
             if (mHasInputSurface && android::media::codec::provider_->input_surface_throttle()) {
                 Mutexed<InputSurface>::Locked inputSurface(mInputSurface);
                 --inputSurface->numProcessingBuffersBalance;
-                ALOGV("[%s] onOutputBufferAvailable: numProcessingBuffersBalance = %lld",
-                      mName, static_cast<long long>(inputSurface->numProcessingBuffersBalance));
+                ALOGV("[%s] onWorkDone: numProcessingBuffersBalance = %lld",
+                        mName, static_cast<long long>(inputSurface->numProcessingBuffersBalance));
             }
-            mCallback->onOutputBufferAvailable(index, outBuffer);
             break;
         }
         case OutputBuffers::REALLOCATE: