SpeakHere loudspeaker crash after application comes to the fore

I am writing a small audio recorder / player for use on my iPad, based on Apple's SpeakHere audio application example. When the user asks for the recorder to display, the UIView opens and displays the record / stop buttons and counters.

When I download the application from scratch, I can record, stop recording, record again anytime I want. After stopping the recording, I put the application in the background, for example, to read my mail. When re-placing the foreground of audio recordings, it is not possible to record sound. I received an error message in my log, the counter does not display any data, and the sound file is not created. I noticed the same behavior with the SpeakHere sample application on both the iPhone and iPad. The only solution is to exit and restart the application.

To deal with this, I decided to turn off the view controller when the user finished using the recorder. I disabled ARC for the record view controller and wrote its dealloc method. In the viewDidDisappear of this controller, I put a call to [self dealloc].

But the program will fail by sending the message [RecorderViewController childViewControllersCount]: sent to the freed instance. I believe that such self-disclosure is not allowed ...

I need to find a solution, either ...

  • Find a way to properly manage audio when the application goes into the background (when recording is stopped, I don’t understand why such a problem occurs).

  • Or, correctly release the recorder's view controller when its view is closed, to ensure that at any time when the view appears, it is loaded again from the controller's XIB file.

[UPDATED] . After looking at the aurioTouch application code (another example audio for the Apple dev website), I added the following code to my application delegate:

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    AudioSessionSetActive(true);

}

, , SpeakHere... , , !

+5

All Articles