summaryrefslogtreecommitdiffstats
path: root/media/libmedia/ToneGenerator.cpp
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-03-28 11:58:45 -0700
committerEric Laurent <elaurent@google.com>2013-03-28 12:00:34 -0700
commita8eccec73a40d4afcff505eb463a016c89aeed42 (patch)
treee304973e7ef3e3a4e460487df22770301914b130 /media/libmedia/ToneGenerator.cpp
parent681be0398a06da7e24db4ed934a92af64d1409b1 (diff)
downloadframeworks_av-a8eccec73a40d4afcff505eb463a016c89aeed42.zip
frameworks_av-a8eccec73a40d4afcff505eb463a016c89aeed42.tar.gz
frameworks_av-a8eccec73a40d4afcff505eb463a016c89aeed42.tar.bz2
ToneGenerator: fix overflow in stopTone
Fix overflow in tone duration calculation introduced in commit 681be039. Bug 6607077 Change-Id: Ie12f13701345c2b2d3be0b3c4d71cbfa2394a29b
Diffstat (limited to 'media/libmedia/ToneGenerator.cpp')
-rw-r--r--media/libmedia/ToneGenerator.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/media/libmedia/ToneGenerator.cpp b/media/libmedia/ToneGenerator.cpp
index 9ea3ea7..f09ce75 100644
--- a/media/libmedia/ToneGenerator.cpp
+++ b/media/libmedia/ToneGenerator.cpp
@@ -986,7 +986,7 @@ void ToneGenerator::stopTone() {
// If the start time is valid, make sure that the number of audio samples produced
// corresponds at least to the time between the start and stop commands.
// This is needed in case of cold start of the output stream.
- if ((mStartTime. tv_sec != 0) && (clock_gettime(CLOCK_MONOTONIC, &stopTime) == 0)) {
+ if ((mStartTime.tv_sec != 0) && (clock_gettime(CLOCK_MONOTONIC, &stopTime) == 0)) {
time_t sec = stopTime.tv_sec - mStartTime.tv_sec;
long nsec = stopTime.tv_nsec - mStartTime.tv_nsec;
long durationMs;
@@ -1000,7 +1000,7 @@ void ToneGenerator::stopTone() {
} else {
// mSamplingRate is always > 1000
sec = sec * 1000 + nsec / 1000000; // duration in milliseconds
- mMaxSmp = (sec * mSamplingRate) / 1000;
+ mMaxSmp = (unsigned int)(((int64_t)sec * mSamplingRate) / 1000);
}
ALOGV("stopTone() forcing mMaxSmp to %d, total for far %d", mMaxSmp, mTotalSmp);
} else {