EXC_BAD_ACCESS Sound error - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: iPhone, iPad & iPod Game Development (/forum-11.html)
+--- Thread: EXC_BAD_ACCESS Sound error (/thread-1913.html)
EXC_BAD_ACCESS Sound error - wonza - Jan 15, 2009 02:28 PM
Im using the SoundEngine found in the crash lander sample app, I've used this successfully in one project already, but Ive come to implement it in a new project but Im getting a EXC_BAD_ACCESS error. This all runs fine in the simulator too.
Here is some of the code I use to init the sounds:
I've even tried using the same sound samples, with no success. When I type backtrace into the console I get this:
EXC_BAD_ACCESS Sound error - wonza - Jan 19, 2009 01:35 AM
I just scrapped my code from this and used the one from AnotherJake that he posted in another thread. Thanks for that BTW!
EXC_BAD_ACCESS Sound error - AnotherJake - Jan 19, 2009 06:34 AM
Heh. You're welcome.
EXC_BAD_ACCESS Sound error - wonza - Jan 24, 2009 05:53 AM
Hmm, I still seem to be struggling with EXC_BAD_ACCESS errors with the new code. It doesnt seem to happen everytime, but often enough to be a problem It usually occurs when playing a second sound, but again it doesnt always happen.
This is how I'm using it:
I'm closing the sound effect from what was previously played so I can play the new one. Im not sure if this is the best way, but this is the only way I could think to get it to work.
Any help is greatly appreciated! Thanks!
EXC_BAD_ACCESS Sound error - AnotherJake - Jan 24, 2009 09:23 AM
You have to release it before you play the next one, or bad things can happen.
I've noticed trouble from time to time with certain file formats. You might try re-exporting or re-encoding your audio file if it continues to be a problem. That issue is a bug with the OS as far as I can tell.
Lastly, for short sounds, you really should be using OpenAL (PITA to figure out, look at oalTouch or CrashLanding sample) or maybe AudioServicesPlaySystemSound (looks dead simple to use but I haven't tried it myself). Use GBMusicTrack for background music, because it was designed primarily to support playing compressed audio like mp3 and m4a, etc. And actually, I've personally been using AVAudioPlayer for background music since iPhone OS 2.2 because it offers the same capabilities as GBMusicTrack but is maintained by Apple.
EXC_BAD_ACCESS Sound error - wonza - Jan 26, 2009 03:35 AM
I went back and tried the sound code form the CrashLanding example, and it worked fine. It must have been a seperate problem that I had the first time I used it.