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

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

Merge "MediaCodec: Use IProducerListener and MediaCodec's generation number"...

Merge "MediaCodec: Use IProducerListener and MediaCodec's generation number" into main am: f73c1e1c

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



Change-Id: Ic00d99ceacab5981c3638ed2a9aec93a105b52b6
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 137de764 f73c1e1c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -2370,6 +2370,11 @@ void Codec2Client::Component::stopUsingOutputSurface(
    mOutputBufferQueue->expireOldWaiters();
}

void Codec2Client::Component::onBufferReleasedFromOutputSurface(
        uint32_t generation) {
    (void) generation;
}

c2_status_t Codec2Client::Component::connectToInputSurface(
        const std::shared_ptr<InputSurface>& inputSurface,
        std::shared_ptr<InputSurfaceConnection>* connection) {
+4 −0
Original line number Diff line number Diff line
@@ -474,6 +474,10 @@ struct Codec2Client::Component : public Codec2Client::Configurable {
    void stopUsingOutputSurface(
            C2BlockPool::local_id_t blockPoolId);

    // Notify a buffer is released from output surface.
    void onBufferReleasedFromOutputSurface(
            uint32_t generation);

    // Connect to a given InputSurface.
    c2_status_t connectToInputSurface(
            const std::shared_ptr<InputSurface>& inputSurface,
+5 −3
Original line number Diff line number Diff line
@@ -867,6 +867,8 @@ void CCodec::configure(const sp<AMessage> &msg) {
        sp<Surface> surface;
        if (msg->findObject("native-window", &obj)) {
            surface = static_cast<Surface *>(obj.get());
            int32_t generation;
            (void)msg->findInt32("native-window-generation", &generation);
            // setup tunneled playback
            if (surface != nullptr) {
                Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig);
@@ -901,7 +903,7 @@ void CCodec::configure(const sp<AMessage> &msg) {
                    }
                }
            }
            setSurface(surface);
            setSurface(surface, (uint32_t)generation);
        }

        Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig);
@@ -2041,7 +2043,7 @@ void CCodec::release(bool sendCallback, bool pushBlankBuffer) {
    }
}

status_t CCodec::setSurface(const sp<Surface> &surface) {
status_t CCodec::setSurface(const sp<Surface> &surface, uint32_t generation) {
    bool pushBlankBuffer = false;
    {
        Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig);
@@ -2070,7 +2072,7 @@ status_t CCodec::setSurface(const sp<Surface> &surface) {
        }
        pushBlankBuffer = config->mPushBlankBuffersOnStop;
    }
    return mChannel->setSurface(surface, pushBlankBuffer);
    return mChannel->setSurface(surface, generation, pushBlankBuffer);
}

void CCodec::signalFlush() {
+6 −7
Original line number Diff line number Diff line
@@ -1132,6 +1132,10 @@ void CCodecBufferChannel::pollForRenderedBuffers() {
    processRenderedFrames(delta);
}

void CCodecBufferChannel::onBufferReleasedFromOutputSurface(uint32_t generation) {
    mComponent->onBufferReleasedFromOutputSurface(generation);
}

status_t CCodecBufferChannel::discardBuffer(const sp<MediaCodecBuffer> &buffer) {
    ALOGV("[%s] discardBuffer: %p", mName, buffer.get());
    bool released = false;
@@ -2285,12 +2289,8 @@ void CCodecBufferChannel::sendOutputBuffers() {
    }
}

status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, bool pushBlankBuffer) {
    static std::atomic_uint32_t surfaceGeneration{0};
    uint32_t generation = (getpid() << 10) |
            ((surfaceGeneration.fetch_add(1, std::memory_order_relaxed) + 1)
                & ((1 << 10) - 1));

status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface,
                                         uint32_t generation, bool pushBlankBuffer) {
    sp<IGraphicBufferProducer> producer;
    int maxDequeueCount;
    sp<Surface> oldSurface;
@@ -2304,7 +2304,6 @@ status_t CCodecBufferChannel::setSurface(const sp<Surface> &newSurface, bool pus
        newSurface->setDequeueTimeout(kDequeueTimeoutNs);
        newSurface->setMaxDequeuedBufferCount(maxDequeueCount);
        producer = newSurface->getIGraphicBufferProducer();
        producer->setGenerationNumber(generation);
    } else {
        ALOGE("[%s] setting output surface to null", mName);
        return INVALID_OPERATION;
+2 −1
Original line number Diff line number Diff line
@@ -91,6 +91,7 @@ public:
    status_t renderOutputBuffer(
            const sp<MediaCodecBuffer> &buffer, int64_t timestampNs) override;
    void pollForRenderedBuffers() override;
    void onBufferReleasedFromOutputSurface(uint32_t generation) override;
    status_t discardBuffer(const sp<MediaCodecBuffer> &buffer) override;
    void getInputBufferArray(Vector<sp<MediaCodecBuffer>> *array) override;
    void getOutputBufferArray(Vector<sp<MediaCodecBuffer>> *array) override;
@@ -105,7 +106,7 @@ public:
    /**
     * Set output graphic surface for rendering.
     */
    status_t setSurface(const sp<Surface> &surface, bool pushBlankBuffer);
    status_t setSurface(const sp<Surface> &surface, uint32_t generation, bool pushBlankBuffer);

    /**
     * Set GraphicBufferSource object from which the component extracts input
Loading