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

Commit caa0b292 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

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

parents 6327ed96 259fb46d
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;
        }