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

Commit b6e9b891 authored by Marco Nelissen's avatar Marco Nelissen
Browse files

Fix gapless SBR

Padding and delay in the file are expressed in terms of the base
sample rate, not in terms of the (doubled) SBR rate.

Change-Id: I3b59ec6281889d24a888c6a079731b05a120807f
parent 0431f4ad
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -224,6 +224,7 @@ private:
    sp<IdleToLoadedState> mIdleToLoadedState;
    sp<FlushingState> mFlushingState;
    sp<SkipCutBuffer> mSkipCutBuffer;
    int32_t mSampleRate;

    AString mComponentName;
    uint32_t mFlags;
+10 −2
Original line number Diff line number Diff line
@@ -494,7 +494,8 @@ void ACodec::BufferInfo::checkReadFence(const char *dbg) {
////////////////////////////////////////////////////////////////////////////////

ACodec::ACodec()
    : mQuirks(0),
    : mSampleRate(0),
      mQuirks(0),
      mNode(0),
      mNativeWindowUsageBits(0),
      mSentFormat(false),
@@ -2452,6 +2453,7 @@ status_t ACodec::setupAACCodec(
    } else {
        ALOGW("did not set AudioAndroidAacPresentation due to error %d when setting AudioAac", res);
    }
    mSampleRate = sampleRate;
    return res;
}

@@ -4464,8 +4466,14 @@ void ACodec::sendFormatChange(const sp<AMessage> &reply) {
        reply->setRect("crop", left, top, right + 1, bottom + 1);
    } else if (mime == MEDIA_MIMETYPE_AUDIO_RAW &&
               (mEncoderDelay || mEncoderPadding)) {
        int32_t channelCount;
        int32_t channelCount, sampleRate;
        CHECK(notify->findInt32("channel-count", &channelCount));
        CHECK(mOutputFormat->findInt32("sample-rate", &sampleRate));
        if (mSampleRate != 0 && sampleRate != 0) {
            mEncoderDelay = mEncoderDelay * sampleRate / mSampleRate;
            mEncoderPadding = mEncoderPadding * sampleRate / mSampleRate;
            mSampleRate = sampleRate;
        }
        if (mSkipCutBuffer != NULL) {
            size_t prevbufsize = mSkipCutBuffer->size();
            if (prevbufsize != 0) {