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

Commit 095c2da8 authored by Dave Burke's avatar Dave Burke
Browse files

Make AAC 5.1 work

Fix bug with pausing audio

Change-Id: Icd6b095dac8d1a68b027de853d11ae02cc070b10
parent 99a80e10
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
LOCAL_PATH:= $(call my-dir)

AAC_LIBRARY = pv
AAC_LIBRARY = fraunhofer

ifeq ($(AAC_LIBRARY), fraunhofer)
  include $(CLEAR_VARS)
@@ -12,7 +12,8 @@ ifeq ($(AAC_LIBRARY), fraunhofer)
          frameworks/av/media/libstagefright/include \
          frameworks/native/include/media/openmax \
          external/aac/libAACdec/include \
          external/aac/libCDK/include \
          external/aac/libPCMutils/include \
          external/aac/libFDK/include \
          external/aac/libMpegTPDec/include \
          external/aac/libSBRdec/include \
          external/aac/libSYS/include
@@ -20,7 +21,7 @@ ifeq ($(AAC_LIBRARY), fraunhofer)
  LOCAL_CFLAGS :=

  LOCAL_STATIC_LIBRARIES := \
          libAACdec libMpegTPDec libSBRdec libCDK libSYS
          libAACdec libMpegTPDec libSBRdec libPCMutils libFDK libSYS

  LOCAL_SHARED_LIBRARIES := \
          libstagefright_omx libstagefright_foundation libutils
+13 −29
Original line number Diff line number Diff line
@@ -26,23 +26,6 @@

namespace android {

static Mutex gAACLibraryLock;
static int gAACLibraryCount = 0;

void initializeAACLibrary() {
  Mutex::Autolock autoLock(gAACLibraryLock);
  if (gAACLibraryCount++ == 0) {
    CDKprolog();
  }
}

void cleanupAACLibrary() {
  Mutex::Autolock autoLock(gAACLibraryLock);
  if (--gAACLibraryCount == 0) {
    CDKepilog();
  }
}

template<class T>
static void InitOMXParams(T *params) {
    params->nSize = sizeof(T);
@@ -63,17 +46,16 @@ SoftAAC2::SoftAAC2(
      mIsADTS(false),
      mInputBufferCount(0),
      mSignalledError(false),
      mInputDiscontinuity(false),
      mAnchorTimeUs(0),
      mNumSamplesOutput(0),
      mOutputPortSettingsChange(NONE) {
    initializeAACLibrary();
    initPorts();
    CHECK_EQ(initDecoder(), (status_t)OK);
}

SoftAAC2::~SoftAAC2() {
    aacDecoder_Close(mAACDecoder);
    cleanupAACLibrary();
}

void SoftAAC2::initPorts() {
@@ -102,7 +84,7 @@ void SoftAAC2::initPorts() {
    def.eDir = OMX_DirOutput;
    def.nBufferCountMin = kNumBuffers;
    def.nBufferCountActual = def.nBufferCountMin;
    def.nBufferSize = 8192;
    def.nBufferSize = 8192 * 2;
    def.bEnabled = OMX_TRUE;
    def.bPopulated = OMX_FALSE;
    def.eDomain = OMX_PortDomainAudio;
@@ -183,6 +165,10 @@ OMX_ERRORTYPE SoftAAC2::internalGetParameter(
            pcmParams->ePCMMode = OMX_AUDIO_PCMModeLinear;
            pcmParams->eChannelMapping[0] = OMX_AUDIO_ChannelLF;
            pcmParams->eChannelMapping[1] = OMX_AUDIO_ChannelRF;
            pcmParams->eChannelMapping[2] = OMX_AUDIO_ChannelCF;
            pcmParams->eChannelMapping[3] = OMX_AUDIO_ChannelLFE;
            pcmParams->eChannelMapping[4] = OMX_AUDIO_ChannelLS;
            pcmParams->eChannelMapping[5] = OMX_AUDIO_ChannelRS;

            if (!isConfigured()) {
                pcmParams->nChannels = 1;
@@ -360,6 +346,7 @@ 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;
        decoderErr = aacDecoder_Fill(mAACDecoder,
                                     inBuffer,
@@ -368,7 +355,8 @@ 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
@@ -447,13 +435,9 @@ void SoftAAC2::onQueueFilled(OMX_U32 portIndex) {

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.
        aacDecoder_DecodeFrame(mAACDecoder,
                               NULL,
                               0,
                               AACDEC_FLUSH);
        mInputDiscontinuity = true;
    }
}

+1 −0
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ private:
    bool mIsADTS;
    size_t mInputBufferCount;
    bool mSignalledError;
    bool mInputDiscontinuity;
    int64_t mAnchorTimeUs;
    int64_t mNumSamplesOutput;