Codec2Cient: Do not hold lock during IGBP operations
In order to minimize lock durations, do not hold locks around
IGBP operations
Bug: 304183768
Test: atest android.media.decoder.cts.AdaptivePlaybackTest
Change-Id: I52729ad8c2b8c54743081fc12c52ff1134d077c1
diff --git a/media/codec2/hal/client/output.cpp b/media/codec2/hal/client/output.cpp
index f86e048..7f4f86b 100644
--- a/media/codec2/hal/client/output.cpp
+++ b/media/codec2/hal/client/output.cpp
@@ -141,11 +141,14 @@
"status = " << INVALID_OPERATION << ".";
return INVALID_OPERATION;
}
- result = igbp->attachBuffer(bqSlot, graphicBuffer);
- if (result == OK) {
- syncVar->notifyDequeuedLocked();
- }
+ syncVar->notifyDequeuedLocked();
syncVar->unlock();
+ result = igbp->attachBuffer(bqSlot, graphicBuffer);
+ if (result != OK) {
+ syncVar->lock();
+ syncVar->notifyQueuedLocked();
+ syncVar->unlock();
+ }
} else {
result = igbp->attachBuffer(bqSlot, graphicBuffer);
}
@@ -435,13 +438,13 @@
auto syncVar = syncMem ? syncMem->mem() : nullptr;
if(syncVar) {
- syncVar->lock();
status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
input, output);
if (status == OK) {
+ syncVar->lock();
syncVar->notifyQueuedLocked();
+ syncVar->unlock();
}
- syncVar->unlock();
} else {
status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
input, output);
@@ -490,13 +493,13 @@
auto syncVar = syncMem ? syncMem->mem() : nullptr;
status_t status = OK;
if (syncVar) {
- syncVar->lock();
status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
input, output);
if (status == OK) {
+ syncVar->lock();
syncVar->notifyQueuedLocked();
+ syncVar->unlock();
}
- syncVar->unlock();
} else {
status = outputIgbp->queueBuffer(static_cast<int>(bqSlot),
input, output);