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

Commit c6a37161 authored by Ben Romberger's avatar Ben Romberger Committed by android-build-merger
Browse files

Merge "libmediaplayerservice: Check for a possible divide by 0"

am: caa0b292

Change-Id: I3048774868263aac5af27591e7b3029309236c08
parents d9624100 caa0b292
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1906,10 +1906,16 @@ status_t MediaPlayerService::AudioOutput::open(
        if (AudioSystem::getOutputSamplingRate(&afSampleRate, mStreamType) != NO_ERROR) {
            return NO_INIT;
        }
        if (afSampleRate == 0) {
            return NO_INIT;
        }
        const size_t framesPerBuffer =
                (unsigned long long)sampleRate * afFrameCount / afSampleRate;

        if (bufferCount == 0) {
            if (framesPerBuffer == 0) {
                return NO_INIT;
            }
            // use suggestedFrameCount
            bufferCount = (suggestedFrameCount + framesPerBuffer - 1) / framesPerBuffer;
        }