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

Commit 00e7ebd0 authored by Dave Burke's avatar Dave Burke Committed by Android Git Automerger
Browse files

am 3748b71a: Handle stream changes at any point in the stream.

* commit '3748b71a':
  Handle stream changes at any point in the stream.
parents 540b65bc 3748b71a
Loading
Loading
Loading
Loading
+15 −33
Original line number Diff line number Diff line
@@ -46,7 +46,6 @@ SoftAAC2::SoftAAC2(
      mIsADTS(false),
      mInputBufferCount(0),
      mSignalledError(false),
      mInputDiscontinuity(false),
      mAnchorTimeUs(0),
      mNumSamplesOutput(0),
      mOutputPortSettingsChange(NONE) {
@@ -364,7 +363,6 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
        INT_PCM *outBuffer = reinterpret_cast<INT_PCM *>(outHeader->pBuffer + outHeader->nOffset);
        bytesValid[0] = inBufferLength[0];

        int flags = mInputDiscontinuity ? AACDEC_INTR : 0;
        int prevSampleRate = mStreamInfo->sampleRate;
        int prevNumChannels = mStreamInfo->numChannels;

@@ -378,26 +376,11 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
            decoderErr = aacDecoder_DecodeFrame(mAACDecoder,
                                                outBuffer,
                                                outHeader->nAllocLen,
                                                flags);
                                                0 /* flags */);

        }
        mInputDiscontinuity = false;

        /*
         * 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) {
        // Check if stream info has changed
        if (mStreamInfo->sampleRate != prevSampleRate ||
            mStreamInfo->numChannels != prevNumChannels) {
            // We're going to want to revisit this input buffer, but
@@ -410,7 +393,6 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {
            mOutputPortSettingsChange = AWAITING_DISABLED;
            return;
        }
        }

        size_t numOutBytes =
            mStreamInfo->frameSize * sizeof(int16_t) * mStreamInfo->numChannels;
@@ -477,7 +459,7 @@ void SoftAAC2::onPortFlushCompleted(OMX_U32 portIndex) {
    if (portIndex == 0) {
        // Make sure that the next buffer output does not still
        // depend on fragments from the last one decoded.
        mInputDiscontinuity = true;
        aacDecoder_SetParam(mAACDecoder, AAC_TPDEC_CLEAR_BUFFER, 1);
        mIsFirst = true;
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ private:
    bool mIsFirst;
    size_t mInputBufferCount;
    bool mSignalledError;
    bool mInputDiscontinuity;
    int64_t mAnchorTimeUs;
    int64_t mNumSamplesOutput;