Loading media/codec2/hal/client/client.cpp +45 −34 Original line number Diff line number Diff line Loading @@ -2391,7 +2391,12 @@ c2_status_t Codec2Client::Component::setOutputSurface( "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; Loading Loading @@ -2419,39 +2424,7 @@ c2_status_t Codec2Client::Component::setOutputSurface( 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" : ""); Loading Loading @@ -2495,6 +2468,44 @@ status_t Codec2Client::Component::queueToOutputSurface( 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 Loading media/codec2/hal/client/include/codec2/hidl/client.h +3 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,9 @@ struct Codec2Client::Component : public Codec2Client::Configurable { const QueueBufferInput& input, QueueBufferOutput* output); // configure consumer usage. uint64_t configConsumerUsage(const sp<IGraphicBufferProducer>& surface); // Retrieve frame event history from the output surface. void pollForRenderedFrames(FrameEventHistoryDelta* delta); Loading Loading
media/codec2/hal/client/client.cpp +45 −34 Original line number Diff line number Diff line Loading @@ -2391,7 +2391,12 @@ c2_status_t Codec2Client::Component::setOutputSurface( "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; Loading Loading @@ -2419,39 +2424,7 @@ c2_status_t Codec2Client::Component::setOutputSurface( 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" : ""); Loading Loading @@ -2495,6 +2468,44 @@ status_t Codec2Client::Component::queueToOutputSurface( 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 Loading
media/codec2/hal/client/include/codec2/hidl/client.h +3 −0 Original line number Diff line number Diff line Loading @@ -467,6 +467,9 @@ struct Codec2Client::Component : public Codec2Client::Configurable { const QueueBufferInput& input, QueueBufferOutput* output); // configure consumer usage. uint64_t configConsumerUsage(const sp<IGraphicBufferProducer>& surface); // Retrieve frame event history from the output surface. void pollForRenderedFrames(FrameEventHistoryDelta* delta); Loading