0

I am having trouble with a frequent crash on the HTC Wildfire S related to sound (there are similar looking, but less frequent, crashes on other devices like Thunderbolt). I have tried a wide variety of things to fix it, or at least learn more about what exactly the problem is without luck.

I am certain the issue is related to sound. When I comment out SoundPool.play() the issue disappears. I don't think it is SoundPool specific since I have tried using OpenSL ES instead which did not reduce the crashes.

I also have a hard time accepting that it is necessarily an issue with lower level sound since it only happens on this title; but not (as far as I have been able to establish) on other games built with the same sound code. In addition I have found virtually no evidence of others experience the same issue.

However game specific things I could think of that would lead to this (lots of simultaneous sounds, frequent sounds, sound format) do not seem to be a problem (I have reduced to only a single sound at a time, switch to WAV, smaller files, OGG, ignore without blocking sounds that happen to recently from another sound).

Our common code is built on top of cocos2dx, and it appears (although I am not wholly convinced) that the crash increased with an adjustment in *Cocos2dxSound.java* so that it would only sleep the main thread after SoundPool.play(...) returned 0 the first time.

Also, in case it could be an issue, some sounds come from the APK are downloaded after installation.

Any ideas or suggestions are greatly appreciated; this has taken way longer than it should have.

VendettaDroid
  • 3,131
  • 2
  • 28
  • 41
ajtc
  • 23
  • 3
  • did you confirmed is it a device related problem or sound specified problem? – m.ding Sep 12 '12 at 00:34
  • what I can suggest is, rewrite the whole cocos2dxSound.java using MediaPlayer implementation (similar with cocos2dxMusic), that will solve the problem, but requires 1-2 days work. That is what I did, and you will benefit from it, such as sequentially playing sound etc. or you can wait a while until the cocos2d-x team to solve the problem, but won't be that fast. – m.ding Sep 12 '12 at 00:40
  • I'll take a look into that, although my concern with MediaPlayer is it is rather resource intensive, especially with simultaneous sounds. The cocos2d-x team is actually the one that suggested I try OpenSL ES. – ajtc Sep 12 '12 at 16:49

2 Answers2

0

It would help if you shared some code. But I recommend you to check this code from ZXing:

http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/BeepManager.java?r=2271

Particularly buildMediaPlayer()

Jorge Cevallos
  • 3,667
  • 3
  • 25
  • 37
0

The issue was due to an unrelated issue. When sounds played it exposed the problem. Unsure what about playing did it; but we suspect playing the sound for whatever reason was putting most low/mid range phones over the edge for memory (ndk-profiler was recently checked in, however it was not disabled when checked in so it was still profiling).

ajtc
  • 23
  • 3