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

Commit 58e32870 authored by Andy Hung's avatar Andy Hung
Browse files

MelProcessor: only log dosage on audio actually delivered

Fixes crash due to dosage check with invalid byte count.

Test: playback run for 15 minutes
Bug: 259220359
Change-Id: I8d7df42baa653ff9477e2f39fce14a9007b3d541
parent b1360ce2
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -3339,17 +3339,19 @@ ssize_t AudioFlinger::PlaybackThread::threadLoop_write()

        if (framesWritten > 0) {
            bytesWritten = framesWritten * mFrameSize;

            // Send to MelProcessor for sound dose measurement.
            auto processor = mMelProcessor.load();
            if (processor) {
                processor->process((char *)mSinkBuffer + offset, bytesWritten);
            }

#ifdef TEE_SINK
            mTee.write((char *)mSinkBuffer + offset, framesWritten);
#endif
        } else {
            bytesWritten = framesWritten;
        }

        auto processor = mMelProcessor.load();
        if (processor) {
            processor->process((char *)mSinkBuffer + offset, bytesWritten);
        }
    // otherwise use the HAL / AudioStreamOut directly
    } else {
        // Direct output and offload threads