简体   繁体   中英

Android SoundPool throwing errors to log file on each user

I'm using SoundPool to play a few sound effects in my android app. The sounds seem to work really well, but I'm getting the following errors posted to my LogCat display

E/AudioTrack: AudioTrack ctr
E/AudioTrack: start 0x2e6068
E/AudioTrack: Underrun user: 0, server: 0, flags 0003
E/AudioTrack: AudioTrack dtor
E/AudioTrack: stop 0x2d4348
E/AudioTrack: Underrun user: bd00, server: bd00, flags 0002
E/AudioTrack: stop 0x2e6068

The sounds are still playing, but occasionally the app is crashing.

Code snippet soundPool:

private void setupSounds() {
    soundPool = new SoundPool(100, AudioManager.STREAM_MUSIC, 100);
    soundPoolMap = new HashMap<String, Integer>(16);

    // Add all note references into a hashmap with the string that will be attached
    soundPoolMap.put("LOWC", soundPool.load(getContext(), R.raw.lowc, 1));
    soundPoolMap.put("LOWD", soundPool.load(getContext(), R.raw.lowd, 1));
    soundPoolMap.put("LOWE", soundPool.load(getContext(), R.raw.lowe, 1));
    soundPoolMap.put("LOWF", soundPool.load(getContext(), R.raw.lowf, 1));
    soundPoolMap.put("LOWG", soundPool.load(getContext(), R.raw.lowg, 1));
    soundPoolMap.put("LOWA", soundPool.load(getContext(), R.raw.lowa, 1));
    soundPoolMap.put("LOWB", soundPool.load(getContext(), R.raw.lowb, 1));
    soundPoolMap.put("LOWZ", soundPool.load(getContext(), R.raw.lowz, 1));
    soundPoolMap.put("MIDDLEC", soundPool.load(getContext(), R.raw.middlec, 1));
    soundPoolMap.put("MIDDLED", soundPool.load(getContext(), R.raw.middled, 1));
    soundPoolMap.put("MIDDLEE", soundPool.load(getContext(), R.raw.middlee, 1));
    soundPoolMap.put("MIDDLEF", soundPool.load(getContext(), R.raw.middlef, 1));
    soundPoolMap.put("MIDDLEG", soundPool.load(getContext(), R.raw.middleg, 1));
    soundPoolMap.put("MIDDLEA", soundPool.load(getContext(), R.raw.middlea, 1));
    soundPoolMap.put("MIDDLEB", soundPool.load(getContext(), R.raw.middleb, 1));
    soundPoolMap.put("MIDDLEZ", soundPool.load(getContext(), R.raw.middlez, 1));
}

And here's where I'm playing the sound

soundPool.play(soundPoolMap.get(getSoundFromHashmap(xPos, yPos)), Constants.VOLUME, Constants.VOLUME, 1, 0, 1f);

From what I've read, this seems like the correct code, so I'm stumped. Any ideas would be appreciated.

Well, I've been testing this app now for about a month and not once has this error caused an exception or any kind of crash. Looks like it's almost like debug information being spewed into the log files, but I don't think it's a concern. For now I'm calling this solved.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM