EDIT: Updated my device (and deployment target) from iOS 4.3.5 to iOS 5.1.1 and still has the same issue
Having a problem releasing a class member AVAudioPlayer to play another sound after playing a sound.
This only seems to be a problem on one of my devices, a 3rd generation iPod Touch running iOS 4.3.5/5.1.1.
My 4th and 5th generation devices running iOS 6 run just fine.
[audio release];
audio = nil;
@try
{
audio = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
if ((audio != nil) && (!error))
{
audio.delegate = (id)self;
audio.volume = gVolume/10;
[audio play];
}
else
{
[audio release];
audio = nil;
}
}
@catch (NSException *exception)
{
[audio release];
audio = nil;
}
First time through it plays just fine, but when this code executes a second time to play another sound, it gives an EXC_BAD_ACCESS error, which does not happen on my 4th/5th generation devices.
I purposely delay the release until I need to play another sound in order to give the play time to perform.
Tried working with AVAudioPlayerDelegate but that didn't solve the problem, nor does calling:
[audio prepareToPlay];
I do initialize audio to nil in viewDidLoad, and clean up in viewDidUnload and dealloc.
Was having a lot of memory leak issues but this version of the code seemed to have solved that.