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

Commit eb61431a authored by Andreas Huber's avatar Andreas Huber
Browse files

Increase AAC software decoder's buffer count. Refactor how clients

of ACodec get notified about codec buffers and buffer ids.

Change-Id: I962f873262dae7aa7b43f5f68a6d60268282f91e
related-to-bug: 6478823
parent 240d8a84
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -56,6 +56,23 @@ struct ACodec : public AHierarchicalStateMachine {
    void initiateConfigureComponent(const sp<AMessage> &msg);
    void initiateStart();

    struct PortDescription : public RefBase {
        size_t countBuffers();
        IOMX::buffer_id bufferIDAt(size_t index) const;
        sp<ABuffer> bufferAt(size_t index) const;

    private:
        friend struct ACodec;

        Vector<IOMX::buffer_id> mBufferIDs;
        Vector<sp<ABuffer> > mBuffers;

        PortDescription();
        void addBuffer(IOMX::buffer_id id, const sp<ABuffer> &buffer);

        DISALLOW_EVIL_CONSTRUCTORS(PortDescription);
    };

protected:
    virtual ~ACodec();

+29 −4
Original line number Diff line number Diff line
@@ -472,14 +472,16 @@ status_t ACodec::allocateBuffersOnPort(OMX_U32 portIndex) {
    notify->setInt32("what", ACodec::kWhatBuffersAllocated);

    notify->setInt32("portIndex", portIndex);

    sp<PortDescription> desc = new PortDescription;

    for (size_t i = 0; i < mBuffers[portIndex].size(); ++i) {
        AString name = StringPrintf("buffer-id_%d", i);
        notify->setPointer(name.c_str(), mBuffers[portIndex][i].mBufferID);
        const BufferInfo &info = mBuffers[portIndex][i];

        name = StringPrintf("data_%d", i);
        notify->setBuffer(name.c_str(), mBuffers[portIndex][i].mData);
        desc->addBuffer(info.mBufferID, info.mData);
    }

    notify->setObject("portDesc", desc);
    notify->post();

    return OK;
@@ -2110,6 +2112,29 @@ void ACodec::signalError(OMX_ERRORTYPE error, status_t internalError) {

////////////////////////////////////////////////////////////////////////////////

ACodec::PortDescription::PortDescription() {
}

void ACodec::PortDescription::addBuffer(
        IOMX::buffer_id id, const sp<ABuffer> &buffer) {
    mBufferIDs.push_back(id);
    mBuffers.push_back(buffer);
}

size_t ACodec::PortDescription::countBuffers() {
    return mBufferIDs.size();
}

IOMX::buffer_id ACodec::PortDescription::bufferIDAt(size_t index) const {
    return mBufferIDs.itemAt(index);
}

sp<ABuffer> ACodec::PortDescription::bufferAt(size_t index) const {
    return mBuffers.itemAt(index);
}

////////////////////////////////////////////////////////////////////////////////

ACodec::BaseState::BaseState(ACodec *codec, const sp<AState> &parentState)
    : AState(parentState),
      mCodec(codec) {
+9 −9
Original line number Diff line number Diff line
@@ -562,20 +562,20 @@ void MediaCodec::onMessageReceived(const sp<AMessage> &msg) {
                    mPortBuffers[portIndex].clear();

                    Vector<BufferInfo> *buffers = &mPortBuffers[portIndex];
                    for (size_t i = 0;; ++i) {
                        AString name = StringPrintf("buffer-id_%d", i);

                        void *bufferID;
                        if (!msg->findPointer(name.c_str(), &bufferID)) {
                            break;
                        }
                    sp<RefBase> obj;
                    CHECK(msg->findObject("portDesc", &obj));

                    sp<ACodec::PortDescription> portDesc =
                        static_cast<ACodec::PortDescription *>(obj.get());

                        name = StringPrintf("data_%d", i);
                    size_t numBuffers = portDesc->countBuffers();

                    for (size_t i = 0; i < numBuffers; ++i) {
                        BufferInfo info;
                        info.mBufferID = bufferID;
                        info.mBufferID = portDesc->bufferIDAt(i);
                        info.mOwnedByClient = false;
                        CHECK(msg->findBuffer(name.c_str(), &info.mData));
                        info.mData = portDesc->bufferAt(i);

                        if (portIndex == kPortIndexInput && mCrypto != NULL) {
                            info.mEncryptedData =
+2 −2
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ void SoftAAC::initPorts() {

    def.nPortIndex = 0;
    def.eDir = OMX_DirInput;
    def.nBufferCountMin = kNumBuffers;
    def.nBufferCountMin = kNumInputBuffers;
    def.nBufferCountActual = def.nBufferCountMin;
    def.nBufferSize = 8192;
    def.bEnabled = OMX_TRUE;
@@ -87,7 +87,7 @@ void SoftAAC::initPorts() {

    def.nPortIndex = 1;
    def.eDir = OMX_DirOutput;
    def.nBufferCountMin = kNumBuffers;
    def.nBufferCountMin = kNumOutputBuffers;
    def.nBufferCountActual = def.nBufferCountMin;
    def.nBufferSize = 8192;
    def.bEnabled = OMX_TRUE;
+2 −1
Original line number Diff line number Diff line
@@ -45,7 +45,8 @@ protected:

private:
    enum {
        kNumBuffers = 4
        kNumInputBuffers        = 32,
        kNumOutputBuffers       = 4,
    };

    tPVMP4AudioDecoderExternal *mConfig;
Loading