SoundEffectsHelper: Update resource info after unloading

SoundEffectsHelper.mResources info needs to be reset
after unloading of samples. Lack of this cleanup is
benign when subsequent resource loading succeeds, but
in case it doesn't having stale info in mResources can
lead to confusion.

Test: atest android.media.cts.AudioManagerTest#testSoundEffects
Change-Id: Ia7a1cc4315bfcf05fa4af915c4ad690183ed4368
This commit is contained in:
Mikhail Naganov
2020-06-25 22:27:17 +00:00
parent d262298b00
commit e7e67fe155

View File

@@ -90,6 +90,10 @@ class SoundEffectsHelper {
mFileName = fileName;
mSampleId = EFFECT_NOT_IN_SOUND_POOL;
}
void unload() {
mSampleId = EFFECT_NOT_IN_SOUND_POOL;
mLoaded = false;
}
}
// All the fields below are accessed by the worker thread exclusively
private final List<Resource> mResources = new ArrayList<Resource>();
@@ -230,6 +234,7 @@ class SoundEffectsHelper {
for (Resource res : mResources) {
if (res.mSampleId != EFFECT_NOT_IN_SOUND_POOL) {
mSoundPool.unload(res.mSampleId);
res.unload();
}
}
mSoundPool.release();