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

Commit 9368cad3 authored by Wonsik Kim's avatar Wonsik Kim Committed by Android (Google) Code Review
Browse files

Merge "codec2: fix output delay update" into qt-dev

parents f182d3ae f0e7d226
Loading
Loading
Loading
Loading
+29 −16
Original line number Diff line number Diff line
@@ -220,7 +220,6 @@ CCodecBufferChannel::CCodecBufferChannel(
        const std::shared_ptr<CCodecCallback> &callback)
    : mHeapSeqNum(-1),
      mCCodecCallback(callback),
      mDelay(0),
      mFrameIndex(0u),
      mFirstValidFrameIndex(0u),
      mMetaMode(MODE_NONE),
@@ -814,7 +813,6 @@ status_t CCodecBufferChannel::start(

    size_t numInputSlots = inputDelayValue + pipelineDelayValue + kSmoothnessFactor;
    size_t numOutputSlots = outputDelayValue + kSmoothnessFactor;
    mDelay = inputDelayValue + pipelineDelayValue + outputDelayValue;

    // TODO: get this from input format
    bool secure = mComponent->getName().find(".secure") != std::string::npos;
@@ -1377,9 +1375,11 @@ bool CCodecBufferChannel::handleWork(
                        (void)mPipelineWatcher.lock()->outputDelay(outputDelay.value);

                        bool outputBuffersChanged = false;
                        size_t numOutputSlots = 0;
                        {
                            Mutexed<Output>::Locked output(mOutput);
                            output->outputDelay = outputDelay.value;
                        size_t numOutputSlots = outputDelay.value + kSmoothnessFactor;
                            numOutputSlots = outputDelay.value + kSmoothnessFactor;
                            if (output->numSlots < numOutputSlots) {
                                output->numSlots = numOutputSlots;
                                if (output->buffers->isArrayMode()) {
@@ -1391,11 +1391,19 @@ bool CCodecBufferChannel::handleWork(
                                    outputBuffersChanged = true;
                                }
                            }
                        output.unlock();
                            numOutputSlots = output->numSlots;
                        }

                        if (outputBuffersChanged) {
                            mCCodecCallback->onOutputBuffersChanged();
                        }

                        uint32_t depth = mReorderStash.lock()->depth();
                        Mutexed<OutputSurface>::Locked output(mOutputSurface);
                        output->maxDequeueBuffers = numOutputSlots + depth + kRenderingDepth;
                        if (output->surface) {
                            output->surface->setMaxDequeuedBufferCount(output->maxDequeueBuffers);
                        }
                    }
                }
                break;
@@ -1620,7 +1628,12 @@ PipelineWatcher::Clock::duration CCodecBufferChannel::elapsed() {
    // When client pushed EOS, we want all the work to be done quickly.
    // Otherwise, component may have stalled work due to input starvation up to
    // the sum of the delay in the pipeline.
    size_t n = mInputMetEos ? 0 : mDelay;
    size_t n = 0;
    if (!mInputMetEos) {
        size_t outputDelay = mOutput.lock()->outputDelay;
        Mutexed<Input>::Locked input(mInput);
        n = input->inputDelay + input->pipelineDelay + outputDelay;
    }
    return mPipelineWatcher.lock()->elapsed(PipelineWatcher::Clock::now(), n);
}

+1 −2
Original line number Diff line number Diff line
@@ -228,8 +228,6 @@ private:
    QueueSync mQueueSync;
    std::vector<std::unique_ptr<C2Param>> mParamsToBeSet;

    size_t mDelay;

    struct Input {
        Input();

@@ -306,6 +304,7 @@ private:
                const C2WorkOrdinalStruct &ordinal);
        void defer(const Entry &entry);
        bool hasPending() const;
        uint32_t depth() const { return mDepth; }

    private:
        std::list<Entry> mPending;