GraphicsTracker: do not call cancelBuffer() after being stopped
When two codecs are using the same surface as below scenario, a buffer in Codec #2 can go inconsistent. Eventually the process using Codec #2 will be aborted. Fix this by not calling cancelBuffer() after GraphicsTracker is stopped.
1. Codec #1: stop using the surface (disconnect)
2. Codec #2: start to use the surface. (connect)
3. Codec #1: cancelBuffer() to the surface in HAL block dtor
4. Codec #2: a buffer by dequeueBuffer() is gone mistakenly by 3
Test: run cts -m CtsMediaStressTestCases
Bug: 354074267
Flag: EXEMPT bugfix
Change-Id: I8489a26021f456a5e9909a3546fc09c958053608
diff --git a/media/codec2/hal/client/GraphicsTracker.cpp b/media/codec2/hal/client/GraphicsTracker.cpp
index 95f5a6e..594e34f 100644
--- a/media/codec2/hal/client/GraphicsTracker.cpp
+++ b/media/codec2/hal/client/GraphicsTracker.cpp
@@ -824,6 +824,10 @@
std::shared_ptr<BufferCache> cache;
int slotId;
sp<Fence> rFence;
+ if (mStopped.load() == true) {
+ ALOGE("cannot deallocate due to being stopped");
+ return C2_BAD_STATE;
+ }
c2_status_t res = requestDeallocate(bid, fence, &completed, &updateDequeue,
&cache, &slotId, &rFence);
if (res != C2_OK) {