I am running an audio file on button tap using AVAudioPlayer (in a calculator app). The issue that I am facing on iOS7 is that whenever the buttons are tapped really fast, the audio player's play method causes an internal error in AVAudioPlayer. Here is the code section
@try
{
if(self.allAudioPlayers == nil)
{
[self initializePlayer];
}
AVAudioPlayer *player = [self grabPlayer];
if(player != nil)
{
NSLog(@"Playing....");
[player play]; //Crashing Here
}
else
{
NSLog(@"Player nil");
}
}
@catch (NSException *exception)
{
NSLog(@"playCalculatorTickSound Exception: %@", [exception description]);
NSLog(@"Call Stack: %@", [exception callStackSymbols]);
}
Once I got this issue ResolveOpageRef and now I am getting this issue _platform_memmov$VARIANT$CortexA8.
Here is another image of the call stack (it is never the same and varies at some level)
My exception handling code is not catching the exception since its an internal error. Is there anyway to catch this, so that the app doesn't get crashed?
I am using threads to call this method. I am not sure but may be multiple threads are trying to read the file at the same time and [player play] is handling the synchronization of the threads and failing to do so.
Thanks in advance