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

Commit 5f42113f authored by Lajos Molnar's avatar Lajos Molnar
Browse files

stagefright: allow to resubmit CSDs for SoftAAC2

Bug: 17118001
Change-Id: I45469b9aa6146edf3265b0f05f5ce3592b5daca6
parent 143a951f
Loading
Loading
Loading
Loading
+201 −208
Original line number Diff line number Diff line
@@ -493,6 +493,7 @@ int32_t SoftAAC2::outputDelayRingBufferSamplesLeft() {
    return mOutputDelayRingBufferSize - outputDelayRingBufferSamplesAvailable();
}


void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
    if (mSignalledError || mOutputPortSettingsChange != NONE) {
        return;
@@ -505,7 +506,15 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
    List<BufferInfo *> &inQueue = getPortQueue(0);
    List<BufferInfo *> &outQueue = getPortQueue(1);

    if (portIndex == 0 && mInputBufferCount == 0) {
    while ((!inQueue.empty() || mEndOfInput) && !outQueue.empty()) {
        if (!inQueue.empty()) {
            INT_PCM tmpOutBuffer[2048 * MAX_CHANNEL_COUNT];
            BufferInfo *inInfo = *inQueue.begin();
            OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;

            mEndOfInput = (inHeader->nFlags & OMX_BUFFERFLAG_EOS) != 0;
            if (portIndex == 0 &&
                    (inHeader->nFlags & OMX_BUFFERFLAG_CODECCONFIG) != 0) {
                BufferInfo *inInfo = *inQueue.begin();
                OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;

@@ -529,6 +538,7 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {

                inInfo->mOwnedByUs = false;
                inQueue.erase(inQueue.begin());
                mLastInHeader = NULL;
                inInfo = NULL;
                notifyEmptyBufferDone(inHeader);
                inHeader = NULL;
@@ -544,22 +554,9 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
                    notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
                    mOutputPortSettingsChange = AWAITING_DISABLED;
                }

                return;
            }

    while ((!inQueue.empty() || mEndOfInput) && !outQueue.empty()) {
        if (!inQueue.empty()) {
            INT_PCM tmpOutBuffer[2048 * MAX_CHANNEL_COUNT];
            BufferInfo *inInfo = *inQueue.begin();
            OMX_BUFFERHEADERTYPE *inHeader = inInfo->mHeader;

            if (inHeader->nFlags & OMX_BUFFERFLAG_EOS) {
                mEndOfInput = true;
            } else {
                mEndOfInput = false;
            }

            if (inHeader->nFilledLen == 0) {
                inInfo->mOwnedByUs = false;
                inQueue.erase(inQueue.begin());
@@ -567,7 +564,9 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
                inInfo = NULL;
                notifyEmptyBufferDone(inHeader);
                inHeader = NULL;
            } else {
                continue;
            }

            if (mIsADTS) {
                size_t adtsHeaderSize = 0;
                // skip 30 bits, aac_frame_length follows.
@@ -609,12 +608,7 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {

                if (signalError) {
                    mSignalledError = true;

                        notify(OMX_EventError,
                               OMX_ErrorStreamCorrupt,
                               ERROR_MALFORMED,
                               NULL);

                    notify(OMX_EventError, OMX_ErrorStreamCorrupt, ERROR_MALFORMED, NULL);
                    return;
                }
            } else {
@@ -759,7 +753,6 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
                ALOGV("inHeader->nFilledLen = %d", inHeader->nFilledLen);
            }
        }
        }

        int32_t outputDelay = mStreamInfo->outputDelay * mStreamInfo->numChannels;