fix audioflinger integer multiplication overflow

when underrun duration is over 3 sec, overflow happens
for multiplication of nsec=sec*1000000000. Use correct format transform
to solve it.

Bug: 135075416
Test: run MTBF test

Change-Id: I0a09ca41f2fad055ce0cfa18f936131b7a630f52
gugelfrei
wendy lin 5 years ago committed by Glenn Kasten
parent 433ccf7dca
commit c08f261af0

@ -309,7 +309,7 @@ bool FastThread::threadLoop()
// compute the delta value of clock_gettime(CLOCK_MONOTONIC)
uint32_t monotonicNs = nsec;
if (sec > 0 && sec < 4) {
monotonicNs += sec * 1000000000;
monotonicNs += sec * 1000000000U; // unsigned to prevent signed overflow.
}
// compute raw CPU load = delta value of clock_gettime(CLOCK_THREAD_CPUTIME_ID)
uint32_t loadNs = 0;
@ -325,7 +325,7 @@ bool FastThread::threadLoop()
}
loadNs = nsec;
if (sec > 0 && sec < 4) {
loadNs += sec * 1000000000;
loadNs += sec * 1000000000U; // unsigned to prevent signed overflow.
}
} else {
// first time through the loop

Loading…
Cancel
Save