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

Commit 9b698dcf authored by Dan Austin's avatar Dan Austin Committed by android-build-merger
Browse files

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

am: a38594e9

* commit 'a38594e9':
  Refactor setPlaybackRate to avoid benign unsigned integer overflow.
parents b8e13b1b a38594e9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -831,13 +831,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;