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

Commit 87c8e5e1 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 6485046 from 6be6f96b to mainline-release

Change-Id: I44f3728743868562902bd75af08d1b7589a6beb6
parents f5afeb95 6be6f96b
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -336,11 +336,10 @@ void C2SoftAmrDec::process(
                memset(output, 0, outSamples * sizeof(int16_t));
            } else {
                int16_t FT;
                RX_State_wb rx_state;
                int16_t numRecSamples;

                mime_unsorting(const_cast<uint8_t *>(&input[1]),
                               mInputSampleBuffer, &FT, &FM, 1, &rx_state);
                               mInputSampleBuffer, &FT, &FM, 1, &mRxState);
                pvDecoder_AmrWb(FM, mInputSampleBuffer, output, &numRecSamples,
                                mDecoderBuf, FT, mDecoderCookie);
                if (numRecSamples != outSamples) {
+3 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@
#define ANDROID_C2_SOFT_AMR_DEC_H_

#include <SimpleC2Component.h>
#include "gsmamr_dec.h"
#include "pvamrwbdecoder.h"


namespace android {
@@ -51,6 +53,7 @@ private:
    void *mAmrHandle;
    void *mDecoderBuf;
    int16_t *mDecoderCookie;
    RX_State_wb mRxState{};

    int16_t mInputSampleBuffer[477];

+9 −5
Original line number Diff line number Diff line
@@ -1379,7 +1379,7 @@ void CCodec::initiateStop() {
        state->set(STOPPING);
    }

    mChannel->stop();
    mChannel->reset();
    (new AMessage(kWhatStop, this))->post();
}

@@ -1406,9 +1406,6 @@ void CCodec::stop() {
        // TODO: convert err into status_t
        mCallback->onError(UNKNOWN_ERROR, ACTION_CODE_FATAL);
    }
    // Assure buffers are not owned when stop() was called without flush().
    std::list<std::unique_ptr<C2Work>> flushedWork;
    mChannel->flush(flushedWork);

    {
        Mutexed<std::unique_ptr<Config>>::Locked configLocked(mConfig);
@@ -1468,7 +1465,7 @@ void CCodec::initiateRelease(bool sendCallback /* = true */) {
        }
    }

    mChannel->stop();
    mChannel->reset();
    // thiz holds strong ref to this while the thread is running.
    sp<CCodec> thiz(this);
    std::thread([thiz, sendCallback] { thiz->release(sendCallback); }).detach();
@@ -1495,6 +1492,7 @@ void CCodec::release(bool sendCallback) {
        state->set(RELEASED);
        state->comp.reset();
    }
    (new AMessage(kWhatRelease, this))->post();
    if (sendCallback) {
        mCallback->onReleaseCompleted();
    }
@@ -1759,6 +1757,12 @@ void CCodec::onMessageReceived(const sp<AMessage> &msg) {
            flush();
            break;
        }
        case kWhatRelease: {
            mChannel->release();
            mClient.reset();
            mClientListener.reset();
            break;
        }
        case kWhatCreateInputSurface: {
            // Surface operations may be briefly blocking.
            setDeadline(now, 1500ms, "createInputSurface");
+53 −16
Original line number Diff line number Diff line
@@ -713,7 +713,7 @@ void CCodecBufferChannel::feedInputBufferIfAvailableInternal() {
        return;
    } else {
        Mutexed<Output>::Locked output(mOutput);
        if (output->buffers->numClientBuffers() >= output->numSlots) {
        if (!output->buffers || output->buffers->numClientBuffers() >= output->numSlots) {
            return;
        }
    }
@@ -1401,6 +1401,30 @@ void CCodecBufferChannel::stop() {
    }
}

void CCodecBufferChannel::reset() {
    stop();
    {
        Mutexed<Input>::Locked input(mInput);
        input->buffers.reset(new DummyInputBuffers(""));
    }
    {
        Mutexed<Output>::Locked output(mOutput);
        output->buffers.reset();
    }
}

void CCodecBufferChannel::release() {
    mComponent.reset();
    mInputAllocator.reset();
    mOutputSurface.lock()->surface.clear();
    {
        Mutexed<BlockPools>::Locked blockPools{mBlockPools};
        blockPools->inputPool.reset();
        blockPools->outputPoolIntf.reset();
    }
}


void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushedWork) {
    ALOGV("[%s] flush", mName);
    {
@@ -1431,8 +1455,10 @@ void CCodecBufferChannel::flush(const std::list<std::unique_ptr<C2Work>> &flushe
    }
    {
        Mutexed<Output>::Locked output(mOutput);
        if (output->buffers) {
            output->buffers->flush(flushedWork);
        }
    }
    mReorderStash.lock()->flush();
    mPipelineWatcher.lock()->flush();
}
@@ -1469,8 +1495,12 @@ bool CCodecBufferChannel::handleWork(
        std::unique_ptr<C2Work> work,
        const sp<AMessage> &outputFormat,
        const C2StreamInitDataInfo::output *initData) {
    if (outputFormat != nullptr) {
    {
        Mutexed<Output>::Locked output(mOutput);
        if (!output->buffers) {
            return false;
        }
        if (outputFormat != nullptr) {
            ALOGD("[%s] onWorkDone: output format changed to %s",
                    mName, outputFormat->debugString().c_str());
            output->buffers->setFormat(outputFormat);
@@ -1486,6 +1516,7 @@ bool CCodecBufferChannel::handleWork(
                }
            }
        }
    }

    if ((work->input.ordinal.frameIndex - mFirstValidFrameIndex.load()).peek() < 0) {
        // Discard frames from previous generation.
@@ -1606,6 +1637,9 @@ bool CCodecBufferChannel::handleWork(
                        size_t numInputSlots = mInput.lock()->numSlots;
                        {
                            Mutexed<Output>::Locked output(mOutput);
                            if (!output->buffers) {
                                return false;
                            }
                            output->outputDelay = outputDelay.value;
                            numOutputSlots = outputDelay.value + kSmoothnessFactor;
                            if (output->numSlots < numOutputSlots) {
@@ -1695,7 +1729,7 @@ bool CCodecBufferChannel::handleWork(

    if (initData != nullptr) {
        Mutexed<Output>::Locked output(mOutput);
        if (output->buffers->registerCsd(initData, &index, &outBuffer) == OK) {
        if (output->buffers && output->buffers->registerCsd(initData, &index, &outBuffer) == OK) {
            outBuffer->meta()->setInt64("timeUs", timestamp.peek());
            outBuffer->meta()->setInt32("flags", MediaCodec::BUFFER_FLAG_CODECCONFIG);
            ALOGV("[%s] onWorkDone: csd index = %zu [%p]", mName, index, outBuffer.get());
@@ -1758,6 +1792,9 @@ void CCodecBufferChannel::sendOutputBuffers() {
        }

        Mutexed<Output>::Locked output(mOutput);
        if (!output->buffers) {
            return;
        }
        status_t err = output->buffers->registerBuffer(entry.buffer, &index, &outBuffer);
        if (err != OK) {
            bool outputBuffersChanged = false;
+10 −0
Original line number Diff line number Diff line
@@ -138,6 +138,16 @@ public:
     */
    void stop();

    /**
     * Stop queueing buffers to the component and release all buffers.
     */
    void reset();

    /**
     * Release all resources.
     */
    void release();

    void flush(const std::list<std::unique_ptr<C2Work>> &flushedWork);

    /**
Loading