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
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index a566e19..6a9876b 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3339,17 +3339,19 @@
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