Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 84677267 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Codec2Client AIDL: config output surface consumer usage" into main am:...

Merge "Codec2Client AIDL: config output surface consumer usage" into main am: 4dc97674 am: bc51315f

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



Change-Id: I0195c005de1feda1bc98259e675019e81af51e93
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 6dd512f5 bc51315f
Loading
Loading
Loading
Loading
+45 −34
Original line number Diff line number Diff line
@@ -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;
@@ -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" : "");

@@ -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
+3 −0
Original line number Diff line number Diff line
@@ -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);