0

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.

chris84948
  • 3,940
  • 3
  • 22
  • 25
  • What format are your sounds? – Ken Wolf Jul 12 '13 at 14:21
  • I'm using MP3, and each file is about 20kb. – chris84948 Jul 12 '13 at 14:28
  • I can't think of anything definitive, indeed your code looks fine. Try converting to .ogg if possible (various sources mention this) and trying that. I have an app that uses soundpool and it uses ogg files...it's been a while but there must have been a reason for it! Also I would try reducing the max simultaneous number. – Ken Wolf Jul 12 '13 at 14:30
  • I had it at 10 originally, but I wondered if I was hitting the max number of files, or something to do with that, so I increased it to 100. I'll give the OGG files a try and get back to you. – chris84948 Jul 12 '13 at 15:25
  • Yea that's not doing anything for me. It seems exactly the same. – chris84948 Jul 12 '13 at 16:33
  • Ah well, maybe someone else will have a suggestion. Only other thing I could find was this: http://stackoverflow.com/questions/6484574/how-bad-is-android-soundpool-what-alternative-to-use – Ken Wolf Jul 12 '13 at 16:55

1 Answers1

0

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.

chris84948
  • 3,940
  • 3
  • 22
  • 25