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

Commit bdfaf7e6 authored by Glenn Kasten's avatar Glenn Kasten Committed by android-build-merger
Browse files

Merge "Limit notification period when a fast track denied" am: 89a1e538 am: 66446e61

am: 53a82d0a

Change-Id: Idf2b0e981ddbae38aeb4838595e303d0b8b1da2f
parents 67d876b1 53a82d0a
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -1393,14 +1393,14 @@ status_t AudioTrack::createTrack_l()

        bool useCaseAllowed = sharedBuffer || transferAllowed;
        if (!useCaseAllowed) {
            ALOGW("AUDIO_OUTPUT_FLAG_FAST denied, not shared buffer and transfer = %s",
            ALOGW("AUDIO_OUTPUT_FLAG_FAST denied by client, not shared buffer and transfer = %s",
                  convertTransferToText(mTransfer));
        }

        // sample rates must also match
        bool sampleRateAllowed = mSampleRate == mAfSampleRate;
        if (!sampleRateAllowed) {
            ALOGW("AUDIO_OUTPUT_FLAG_FAST denied, rates do not match %u Hz, require %u Hz",
            ALOGW("AUDIO_OUTPUT_FLAG_FAST denied by client, sample rate %u Hz but HAL needs %u Hz",
                  mSampleRate, mAfSampleRate);
        }

@@ -1578,6 +1578,15 @@ status_t AudioTrack::createTrack_l()
            // or at least triple-buffering if there is sample rate conversion
            const int nBuffering = mOriginalSampleRate == mAfSampleRate ? 2 : 3;
            maxNotificationFrames = frameCount / nBuffering;
            // If client requested a fast track but this was denied, then use the smaller maximum.
            // FMS_20 is the minimum task wakeup period in ms for which CFS operates reliably.
#define FMS_20 20   // FIXME share a common declaration with the same symbol in Threads.cpp
            if (mOrigFlags & AUDIO_OUTPUT_FLAG_FAST) {
                size_t maxNotificationFramesFastDenied = FMS_20 * mSampleRate / 1000;
                if (maxNotificationFrames > maxNotificationFramesFastDenied) {
                    maxNotificationFrames = maxNotificationFramesFastDenied;
                }
            }
        }
        if (mNotificationFramesAct == 0 || mNotificationFramesAct > maxNotificationFrames) {
            if (mNotificationFramesAct == 0) {