Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Strange crashes on device — Gideros Forum

Strange crashes on device

PaulHPaulH Member
edited February 2013 in General questions
Hey, all. My game is nearly finished and runs indefinitely on the Player, but crashes randomly on Android devices. One one test device (Kindle Fire) each sound stops a split second before the end, but on other devices they play to the end. When testing in Eclipse on my phone the only hint in the LogCat are numerous instances of this warning:

02-26 17:11:38.350: W/MediaPlayer(3440): mediaplayer went away with unhandled events

I've triple checked that the cases match between the files and the references in the project, and the function I use to play sounds checks for the existence of a file before trying to create a sound with it, so I can put in code like play_sound("no_such_file.mp3") without causing a crash.

Any other ideas of what could cause the mediaplayer error?

PaulH

Comments

  • Not sure what the cause could be, but mp3 files have quite a lag on android and are not recommended for short sound effects - wav files should be used instead and mp3 only used for longer sounds such as background music. In the past I've had to change mp3s to wav files to get them to play properly.
  • Thanks for the tip - that's very interesting. I've tried disabling all the sounds and so far it seems stable. I still saw one instance of the mediaplayer error in LogCat, but the crashes seem to be solved, suggesting they really are an issue with the sounds. I can certainly change some of the shortest sounds to wav format, but I have quite a lot of relatively short sound files, more than 500 in fact, totaling over 35 minutes. Many are snippets of conversation just a few seconds long. Converting them to wav would make the app excessively large, increasing the total size of the sound files from 12 mb to over 175 mb. They were all wav files in the original Windows version of this game where the size wasn't such an issue.

    Are there any other compressed sound formats that are more reliable than mp3? If not, is there a minimum length at which an mp3 file can be used safely?

    PaulH
  • This thread seems to cover the sound issue quite thoroughly:

    http://www.giderosmobile.com/forum/discussion/331/what-is-the-best-sound-format

    Based on that I think I'll keep all speech, music and looping sounds in mp3 (which is most of them) and convert the others (general sound effects) to wav. I'll see if that helps. As long as it doesn't crash I can find ways to deal with performance issues, avoiding having too many concurrent sounds, maybe adding a fraction of a second of silence on the end of speech to prevent the clipping, etc.

    Thanks again for the reply.

    PaulH
  • Also which Gideros version are you using? There were a sound bug in I think 2012.9.5
  • john26john26 Maintainer
    It may be that Gideros handles all MP3 files by streaming them irrespective of length? This article gives a description of how OpenAL does streaming (hint: it's complicated!).

    http://benbritten.com/2010/05/04/streaming-in-openal/

    Playing lots of MP3 files simultaneously may exhaust the number of sound buffers allowed?

    So my guess (assuming Gideros actually uses OpenAL) is MP3 files are handled completely different from WAV files even if they are the same sound and the MP3 is short. In that case its a good idea to convert to WAV. If you have thousands of short sounds, perhaps put them all together would help?
  • petecpetec Member
    edited February 2013
    When I converted to wav files I experimented with dropping the quality to reduce their file size. I can't remember what I settled on and I altered it depending on how the reduced quality file sounded - some were abe to go lower than others. Very fiddly to do with lots of sound files but worth it overall for reducing the overall size of the app.
  • I'm on version 2012.09.9 of the studio.

    I've just converted all the sounds under 2 seconds long to 16 bit mono wav format. Many of the others are segments of conversations. In the Windows version I kept them in separate files so the code could know which character's mouth to animate depending on the file that's playing. For the mobile version the faces aren't visible during speech, so I'm combining each conversation into a single mp3, 44100 Hz, 48 kbps, mono format. Time to try it on the phone...
  • atilimatilim Maintainer
    edited February 2013
    In Gideros, all MP3 files are handled as streaming music. On iOS, it uses AVAudioPlayer, on Android it uses android.media.MediaPlayer and on desktop it uses libmpg123+OpenAL (streaming).

    Previously, I've also tried libmpg123+OpenAL on iOS and Android but it consumes too much CPU power and therefore I've decided to use the methods provided by the OS (and hoped that they're efficient and using specialised hardware).

    In the future, I want to provide 3 different methods (independent of the file format) so that experienced users can choose the most appropriate one:
    - sample: load all sound data to the memory and play
    - stream: load and play in small fragments with queue buffers
    - background: use OS provided methods where available and if not available (such as desktop) fallback to stream.
  • john26john26 Maintainer
    If I was writing a LucasArts style adventure game with many hours of soundtrack and music what would be the best approach? Would it be a good idea to concatenate all sounds into one large MP3 file (LucasArts games used to have a single huge file called monster.sou). Gideros would then need to be very fast at accessing the small portion of sound needed at any one time...
Sign In or Register to comment.