Hi Halle, Thanks for your response. I plan to experiment a little more with this before providing a detailed response, but thought I’d offer the following per your response now:
I ended up using 2 state booleans, one to track calls to start / stop listening and one to track responses from the callback (didStartListening, isListening).
I did this, because in my app, the user might background / foreground the app at any time, so if startListening has been called once, I wanted to avoid calling it again, regardless of confirmation from the callback. Same with stopListening. I use a combination of the state booleans to determine if/when it is appropriate to call again, based on app in foreground / background or audioSessionInterruptionDidBegin / End.
The crash issue appears to be a cause of the following sequence:
1) PocketsphinxController is listening in the foreground and working correctly.
2) App is backgrounded and stopListening is called.
3) A phone call is made. While call is in progress, my app is moved to foreground (voice recognition is an enhancement, not a requirement for my app to work).
4) Start listening is called because app is in foreground, but the error occurs because the phone call has control over the audio session.
So, what I am exploring is a way to determine through AVFoundation notifications when another app or the phone has control of the audio session and avoid a startListening call, but trigger that call if my app is in the foreground and all other apps have released control of the audio session.
The AVFoundation notifications are a new area for me, so I’m hoping that I can use them to determine when PocketsphinxController can successfuly assume control of the audio session.
Does this make sense? Any other observations on your part? Except for this audio session management issue and the lock screen button sound issue I described earlier, PocketsphinxController works fantastic and stopping / starting works fine relative to backgrounding / foregrounding my app.
I will follow-up with the results of my investigation / testing.