I have an audio app in the store. It works just fine with prior versions of the iPhone software, and with iOS4.0. Recently I started to work on a new version, first by bringing the app into compliance with the new iOS4 multitasking capabilities. (In addition to installing the new OS on my iPhone, I upgraded to the latest SDK.)
The results have been disappointing - at the moment a show-stopper.
o When the app is initially installed on the iPhone, or when started after the iPhone is completely powered down, the app starts just fine - including starting to play audio that was playing the last time the app was run.
o If I try to restart the app from the background, the audio - which plays and mixes 1 - n audio streams
simultaneously - comes out with a stuttering sound that only I could recognize.
o Another detail: If I call the iPhone, I can either answer or decline the call. In both cases the app comes back. playing as it should.
I am not trying to play anything while in background mode. I simply want to shut things off and bring them back when asked.
Technology: All of the audio logic uses RemoteIO. (I have plans for someday doing some fairly sophisticated signal processing,)
Overview of MainViewController:
o viewDidLoad - nothing special
o didBecomeActive
set self as audio session delegate;
set the AudioSessionCategory to
MediaPlayback;
set the AudioSessionActive;
create a Player (see below);
restart any sounds that were previously playing.
o willResignActive
save the state of what was playing;
stopAllSounds;
stop the player.
set the audio session inactive
o didEnterBackground - nothing
o willEnterForeground - nothing
Overview of Player - my
class:
All of the actual playback is in a separate object - a "player".
constructor
setupRemoteIO
start
AudioOutputUnitStart
stop
AudioOutputUnitStop
player callback
the usual stuff
One other detail: The Player is a singleton. I make sure that the singleton instance is destroyed, and a new one created, in didBecomeActive. Instantiating the singleton actually starts the AudioUnit.