diff options
author | Dave Sparks <davidsparks@android.com> | 2009-05-29 19:12:11 -0700 |
---|---|---|
committer | Dave Sparks <davidsparks@android.com> | 2009-06-01 08:16:19 -0700 |
commit | 3c8704b171c812dde6f48e5416ba0b336470dd4a (patch) | |
tree | ca4eaff376c4c5aa2796496beae0bad526c0162e /media/jni/soundpool | |
parent | b0ded43d3844d9d97c5d554e8ca4ec3ee2c7bbe1 (diff) | |
download | frameworks_base-3c8704b171c812dde6f48e5416ba0b336470dd4a.zip frameworks_base-3c8704b171c812dde6f48e5416ba0b336470dd4a.tar.gz frameworks_base-3c8704b171c812dde6f48e5416ba0b336470dd4a.tar.bz2 |
Limit check on maxChannels for SoundPool.
Bug 1838724
Diffstat (limited to 'media/jni/soundpool')
-rw-r--r-- | media/jni/soundpool/SoundPool.cpp | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/media/jni/soundpool/SoundPool.cpp b/media/jni/soundpool/SoundPool.cpp index 0812650..ce80f92 100644 --- a/media/jni/soundpool/SoundPool.cpp +++ b/media/jni/soundpool/SoundPool.cpp @@ -44,23 +44,27 @@ SoundPool::SoundPool(jobject soundPoolRef, int maxChannels, int streamType, int LOGV("SoundPool constructor: maxChannels=%d, streamType=%d, srcQuality=%d", maxChannels, streamType, srcQuality); - if (maxChannels > 32) { - LOGW("App requested %d channels, capped at 32", maxChannels); - maxChannels = 32; + // check limits + mMaxChannels = maxChannels; + if (mMaxChannels < 1) { + mMaxChannels = 1; + } + else if (mMaxChannels > 32) { + mMaxChannels = 32; } + LOGW_IF(maxChannels != mMaxChannels, "App requested %d channels", maxChannels); mQuit = false; mSoundPoolRef = soundPoolRef; mDecodeThread = 0; - mMaxChannels = maxChannels; mStreamType = streamType; mSrcQuality = srcQuality; mAllocated = 0; mNextSampleID = 0; mNextChannelID = 0; - mChannelPool = new SoundChannel[maxChannels]; - for (int i = 0; i < maxChannels; ++i) { + mChannelPool = new SoundChannel[mMaxChannels]; + for (int i = 0; i < mMaxChannels; ++i) { mChannelPool[i].init(this); mChannels.push_back(&mChannelPool[i]); } |