Merge change 2774 into donut
* changes: Limit check on maxChannels for SoundPool. Bug 1838724
This commit is contained in:
@@ -44,23 +44,27 @@ SoundPool::SoundPool(jobject soundPoolRef, int maxChannels, int streamType, int
|
|||||||
LOGV("SoundPool constructor: maxChannels=%d, streamType=%d, srcQuality=%d",
|
LOGV("SoundPool constructor: maxChannels=%d, streamType=%d, srcQuality=%d",
|
||||||
maxChannels, streamType, srcQuality);
|
maxChannels, streamType, srcQuality);
|
||||||
|
|
||||||
if (maxChannels > 32) {
|
// check limits
|
||||||
LOGW("App requested %d channels, capped at 32", maxChannels);
|
mMaxChannels = maxChannels;
|
||||||
maxChannels = 32;
|
if (mMaxChannels < 1) {
|
||||||
|
mMaxChannels = 1;
|
||||||
}
|
}
|
||||||
|
else if (mMaxChannels > 32) {
|
||||||
|
mMaxChannels = 32;
|
||||||
|
}
|
||||||
|
LOGW_IF(maxChannels != mMaxChannels, "App requested %d channels", maxChannels);
|
||||||
|
|
||||||
mQuit = false;
|
mQuit = false;
|
||||||
mSoundPoolRef = soundPoolRef;
|
mSoundPoolRef = soundPoolRef;
|
||||||
mDecodeThread = 0;
|
mDecodeThread = 0;
|
||||||
mMaxChannels = maxChannels;
|
|
||||||
mStreamType = streamType;
|
mStreamType = streamType;
|
||||||
mSrcQuality = srcQuality;
|
mSrcQuality = srcQuality;
|
||||||
mAllocated = 0;
|
mAllocated = 0;
|
||||||
mNextSampleID = 0;
|
mNextSampleID = 0;
|
||||||
mNextChannelID = 0;
|
mNextChannelID = 0;
|
||||||
|
|
||||||
mChannelPool = new SoundChannel[maxChannels];
|
mChannelPool = new SoundChannel[mMaxChannels];
|
||||||
for (int i = 0; i < maxChannels; ++i) {
|
for (int i = 0; i < mMaxChannels; ++i) {
|
||||||
mChannelPool[i].init(this);
|
mChannelPool[i].init(this);
|
||||||
mChannels.push_back(&mChannelPool[i]);
|
mChannels.push_back(&mChannelPool[i]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user