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

Commit 5cbb5785 authored by Andy Hung's avatar Andy Hung
Browse files

Reject sample rate changes for fast tracks

This is needed for a SoundPool fix.

Bug: 19970735
Change-Id: I46b69e059aabf0d06b16b31ea436bb71f7146750
parent 91e5e043
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -667,14 +667,18 @@ void AudioTrack::getAuxEffectSendLevel(float* level) const

status_t AudioTrack::setSampleRate(uint32_t rate)
{
    if (mIsTimed || isOffloadedOrDirect()) {
    AutoMutex lock(mLock);
    if (rate == mSampleRate) {
        return NO_ERROR;
    }
    if (mIsTimed || isOffloadedOrDirect_l() || (mFlags & AUDIO_OUTPUT_FLAG_FAST)) {
        return INVALID_OPERATION;
    }

    AutoMutex lock(mLock);
    if (mOutput == AUDIO_IO_HANDLE_NONE) {
        return NO_INIT;
    }
    // NOTE: it is theoretically possible, but highly unlikely, that a device change
    // could mean a previously allowed sampling rate is no longer allowed.
    uint32_t afSamplingRate;
    if (AudioSystem::getSamplingRate(mOutput, &afSamplingRate) != NO_ERROR) {
        return NO_INIT;