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

Commit a38594e9 authored by Dan Austin's avatar Dan Austin Committed by Gerrit Code Review
Browse files

Merge "Refactor setPlaybackRate to avoid benign unsigned integer overflow."

parents acd2186a e34eae2d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -822,13 +822,13 @@ status_t AudioTrack::setPlaybackRate(const AudioPlaybackRate &playbackRate)
    }

    // Check resampler ratios are within bounds
    if (effectiveRate > mSampleRate * AUDIO_RESAMPLER_DOWN_RATIO_MAX) {
    if ((uint64_t)effectiveRate > (uint64_t)mSampleRate * (uint64_t)AUDIO_RESAMPLER_DOWN_RATIO_MAX) {
        ALOGV("setPlaybackRate(%f, %f) failed. Resample rate exceeds max accepted value",
                playbackRate.mSpeed, playbackRate.mPitch);
        return BAD_VALUE;
    }

    if (effectiveRate * AUDIO_RESAMPLER_UP_RATIO_MAX < mSampleRate) {
    if ((uint64_t)effectiveRate * (uint64_t)AUDIO_RESAMPLER_UP_RATIO_MAX < (uint64_t)mSampleRate) {
        ALOGV("setPlaybackRate(%f, %f) failed. Resample rate below min accepted value",
                        playbackRate.mSpeed, playbackRate.mPitch);
        return BAD_VALUE;