Codec2Client AIDL: config output surface consumer usage
Configuring output surface consumer usage to HAL is missing in C2AIDL.
Add configuring output surface consumer usage to HAL for C2AIDL.
Bug: 361058061
Flag: EXEMPT bugfix
Test: build
Change-Id: I732acc25c4df28082d50a0616d42f318c6f154d3
diff --git a/media/codec2/hal/client/client.cpp b/media/codec2/hal/client/client.cpp
index a137dbb..80735cb 100644
--- a/media/codec2/hal/client/client.cpp
+++ b/media/codec2/hal/client/client.cpp
@@ -2391,7 +2391,12 @@
"GraphicBufferAllocator was not created.";
return C2_CORRUPTED;
}
+ // Note: Consumer usage is set ahead of the HAL allocator(gba) being set.
+ // This is same as HIDL.
+ uint64_t consumerUsage = configConsumerUsage(surface);
bool ret = gba->configure(surface, generation, maxDequeueCount);
+ ALOGD("setOutputSurface -- generation=%u consumer usage=%#llx",
+ generation, (long long)consumerUsage);
return ret ? C2_OK : C2_CORRUPTED;
}
uint64_t bqId = 0;
@@ -2419,41 +2424,9 @@
mHidlBase1_2 ? &syncObj : nullptr);
}
- // set consumer bits
- // TODO: should this get incorporated into setOutputSurface method so that consumer bits
- // can be set atomically?
- uint64_t consumerUsage = kDefaultConsumerUsage;
- {
- if (surface) {
- uint64_t usage = 0;
- status_t err = surface->getConsumerUsage(&usage);
- if (err != NO_ERROR) {
- ALOGD("setOutputSurface -- failed to get consumer usage bits (%d/%s). ignoring",
- err, asString(err));
- } else {
- // Note: we are adding the default usage because components must support
- // producing output frames that can be displayed an all output surfaces.
-
- // TODO: do not set usage for tunneled scenario. It is unclear if consumer usage
- // is meaningful in a tunneled scenario; on one hand output buffers exist, but
- // they do not exist inside of C2 scope. Any buffer usage shall be communicated
- // through the sideband channel.
-
- consumerUsage = usage | kDefaultConsumerUsage;
- }
- }
-
- C2StreamUsageTuning::output outputUsage{
- 0u, C2AndroidMemoryUsage::FromGrallocUsage(consumerUsage).expected};
- std::vector<std::unique_ptr<C2SettingResult>> failures;
- c2_status_t err = config({&outputUsage}, C2_MAY_BLOCK, &failures);
- if (err != C2_OK) {
- ALOGD("setOutputSurface -- failed to set consumer usage (%d/%s)",
- err, asString(err));
- }
- }
+ uint64_t consumerUsage = configConsumerUsage(surface);
ALOGD("setOutputSurface -- generation=%u consumer usage=%#llx%s",
- generation, (long long)consumerUsage, syncObj ? " sync" : "");
+ generation, (long long)consumerUsage, syncObj ? " sync" : "");
Return<c2_hidl::Status> transStatus = syncObj ?
mHidlBase1_2->setOutputSurfaceWithSyncObj(
@@ -2495,6 +2468,44 @@
return mOutputBufferQueue->outputBuffer(block, input, output);
}
+uint64_t Codec2Client::Component::configConsumerUsage(
+ const sp<IGraphicBufferProducer>& surface) {
+ // set consumer bits
+ // TODO: should this get incorporated into setOutputSurface method so that consumer bits
+ // can be set atomically?
+ uint64_t consumerUsage = kDefaultConsumerUsage;
+ {
+ if (surface) {
+ uint64_t usage = 0;
+ status_t err = surface->getConsumerUsage(&usage);
+ if (err != NO_ERROR) {
+ ALOGD("setOutputSurface -- failed to get consumer usage bits (%d/%s). ignoring",
+ err, asString(err));
+ } else {
+ // Note: we are adding the default usage because components must support
+ // producing output frames that can be displayed an all output surfaces.
+
+ // TODO: do not set usage for tunneled scenario. It is unclear if consumer usage
+ // is meaningful in a tunneled scenario; on one hand output buffers exist, but
+ // they do not exist inside of C2 scope. Any buffer usage shall be communicated
+ // through the sideband channel.
+
+ consumerUsage = usage | kDefaultConsumerUsage;
+ }
+ }
+
+ C2StreamUsageTuning::output outputUsage{
+ 0u, C2AndroidMemoryUsage::FromGrallocUsage(consumerUsage).expected};
+ std::vector<std::unique_ptr<C2SettingResult>> failures;
+ c2_status_t err = config({&outputUsage}, C2_MAY_BLOCK, &failures);
+ if (err != C2_OK) {
+ ALOGD("setOutputSurface -- failed to set consumer usage (%d/%s)",
+ err, asString(err));
+ }
+ }
+ return consumerUsage;
+}
+
void Codec2Client::Component::pollForRenderedFrames(FrameEventHistoryDelta* delta) {
if (mAidlBase) {
// TODO b/311348680