Fixed audioserver crash in monkey test
Enable log function in ToneGenerator.cpp, then ToneGenerator
plays consecutively many times and do not stopTone.
"lpToneGen->mNextSegSmp*1000" will go beyond the scope of unsigned
int, and audioserver get crashed.
Test: Enable log function in ToneGenerator.cpp, alarm notification is
played when the phone is online. ToneGenerator plays consecutively.
Do not stopTone. then we get audioserver crash.
Change-Id: I073590088fccb32a73353d14970dc89441045663
diff --git a/media/libaudioclient/ToneGenerator.cpp b/media/libaudioclient/ToneGenerator.cpp
index 5338059..52641d6 100644
--- a/media/libaudioclient/ToneGenerator.cpp
+++ b/media/libaudioclient/ToneGenerator.cpp
@@ -1367,16 +1367,18 @@
lWaveCmd = WaveGenerator::WAVEGEN_START;
}
- ALOGV("New segment %d, Next Time: %d", lpToneGen->mCurSegment,
- (lpToneGen->mNextSegSmp*1000)/lpToneGen->mSamplingRate);
+ ALOGV("New segment %d, Next Time: %lld", lpToneGen->mCurSegment,
+ ((long long)(lpToneGen->mNextSegSmp)*1000)/lpToneGen->mSamplingRate);
+
} else {
lGenSmp = 0;
ALOGV("End repeat, time: %d", (unsigned int)(systemTime()/1000000));
}
} else {
- ALOGV("New segment %d, Next Time: %d", lpToneGen->mCurSegment,
- (lpToneGen->mNextSegSmp*1000)/lpToneGen->mSamplingRate);
+ ALOGV("New segment %d, Next Time: %lld", lpToneGen->mCurSegment,
+ ((long long)(lpToneGen->mNextSegSmp)*1000)/lpToneGen->mSamplingRate);
+
if (lpToneDesc->segments[lpToneGen->mCurSegment].waveFreq[0] != 0) {
// If next segment is not silent, OFF -> ON transition : reset wave generator
lWaveCmd = WaveGenerator::WAVEGEN_START;