Fix arguments capture in SoundEffectsHelper

The handler created for an async call must capture arguments of
the Message by value instead of capturing the instance of
Message by reference. Since Message objects are pooled for
efficiency, a possibility exists that the instance of Message is
reused later.

Bug: 160315111
Bug: 160965418
Test: atest android.media.cts.AudioManagerTest
Change-Id: I2c81b8fa9ae6653da2e6812668395d8fcd6bc6e9
This commit is contained in:
Mikhail Naganov
2020-07-11 01:11:37 +00:00
parent 99abd5c15d
commit f8819552bb

View File

@@ -441,11 +441,12 @@ class SoundEffectsHelper {
onUnloadSoundEffects();
break;
case MSG_PLAY_EFFECT:
final int effect = msg.arg1, volume = msg.arg2;
onLoadSoundEffects(new OnEffectsLoadCompleteHandler() {
@Override
public void run(boolean success) {
if (success) {
onPlaySoundEffect(msg.arg1 /*effect*/, msg.arg2 /*volume*/);
onPlaySoundEffect(effect, volume);
}
}
});