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

Commit bf2461ec authored by Dave Burke's avatar Dave Burke
Browse files

Don't reconfigure stream after outputing data.

Handle invalid configuration.
Bug: 6519161

Change-Id: Ib2d38bee769e63e627c93d7f3839c3a55de694e9
parent 874a897f
Loading
Loading
Loading
Loading
+40 −17
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ OMX_ERRORTYPE SoftAAC2::internalGetParameter(

            aacParams->eChannelMode = OMX_AUDIO_ChannelModeStereo;

            if (!isConfigured() || !mStreamInfo->numChannels || !mStreamInfo->sampleRate) {
            if (!isConfigured()) {
                aacParams->nChannels = 1;
                aacParams->nSampleRate = 44100;
                aacParams->nFrameLength = 0;
@@ -170,7 +170,7 @@ OMX_ERRORTYPE SoftAAC2::internalGetParameter(
            pcmParams->eChannelMapping[4] = OMX_AUDIO_ChannelLS;
            pcmParams->eChannelMapping[5] = OMX_AUDIO_ChannelRS;

            if (!isConfigured() || !mStreamInfo->numChannels || !mStreamInfo->sampleRate) {
            if (!isConfigured()) {
                pcmParams->nChannels = 1;
                pcmParams->nSamplingRate = 44100;
            } else {
@@ -280,6 +280,9 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
        info->mOwnedByUs = false;
        notifyEmptyBufferDone(header);

        ALOGI("Configuring decoder: %d Hz, %d channels",
              mStreamInfo->sampleRate,
              mStreamInfo->numChannels);
        notify(OMX_EventPortSettingsChanged, 1, 0, NULL);
        mOutputPortSettingsChange = AWAITING_DISABLED;
        return;
@@ -377,7 +380,21 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {

        }

        // Check if stream info has changed
        /*
         * AAC+/eAAC+ streams can be signalled in two ways: either explicitly
         * or implicitly, according to MPEG4 spec. AAC+/eAAC+ is a dual
         * rate system and the sampling rate in the final output is actually
         * doubled compared with the core AAC decoder sampling rate.
         *
         * Explicit signalling is done by explicitly defining SBR audio object
         * type in the bitstream. Implicit signalling is done by embedding
         * SBR content in AAC extension payload specific to SBR, and hence
         * requires an AAC decoder to perform pre-checks on actual audio frames.
         *
         * Thus, we could not say for sure whether a stream is
         * AAC+/eAAC+ until the first data frame is decoded.
         */
        if (mInputBufferCount <= 2) {
            if (mStreamInfo->sampleRate != prevSampleRate ||
                mStreamInfo->numChannels != prevNumChannels) {
                ALOGI("Reconfiguring decoder: %d Hz, %d channels",
@@ -394,6 +411,12 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
                mOutputPortSettingsChange = AWAITING_DISABLED;
                return;
            }
        } else if (!mStreamInfo->sampleRate || !mStreamInfo->numChannels) {
            ALOGW("Invalid AAC stream");
            mSignalledError = true;
            notify(OMX_EventError, OMX_ErrorUndefined, decoderErr, NULL);
            return;
        }

        size_t numOutBytes =
            mStreamInfo->frameSize * sizeof(int16_t) * mStreamInfo->numChannels;