With iOS 4 and FMOD, audio playback works fine in the background during a multitasking session until another app interrupts the audio. When my app returns to the foreground, the audio session is no longer valid and no sound is generated. Although, FMOD continues to function as if it had a valid audio session.
I don’t see any callbacks inside FMOD to inform me when the audio session has been interrupted so I know to reinitialize the next time I become active. I do see a system callback for when system audio devices have changed. Is this the callback I’m looking for? Am I missing something or do I have to do this through the iOS apis? If so, is there a way for me to get the audio session handle from FMOD?
I appreciate any help you can provide on this.
- tbraun asked 6 years ago
When the phone is locked we get no notification from the audio APIs, so yes you would need to use the restore function when coming back from a lock in the case of using the AudioQueue codecs. If you are not using AudioQueue codecs everything should be restored correctly by the OS.
That is odd indeed, I have just installed a clean 4.32.01, opened the playsound example and added the following to ExampleAppDelegate.mm. This compiles correctly.
- (void)applicationDidBecomeActive:(UIApplication *)application
You can also verify the lib has the symbol with:
[code:36d530im]nm libfmodex_iphoneos.a | c++filt | grep RestoreAudioSession[/code:36d530im]
I am using the 4.31.05 version has been deployed.
App pause / restore times, I have not seen any error.
However, it still is a developer version.
Does it change when the stable version?
To be able to help stabilize this version do it?
It looks like applicationDidBecomeActive is too unstable at the moment, in my tests the mediaserver process is occasionally crashing. Did become active is not a good fit for this issue anyway since it is triggered in other conditions like overlay text.
We will need to talk to Apple about this, I would recommend using the reset only in the foreground callback for now.
The main difference between development branch and stable branch is API lock down. Once a branch becomes stable we don’t modify the public API so you can safely take new versions.
The other difference is simply time, we except that the development branch will get bugs from the new features being added, so we like to keep the "dev" label on it until we are satisfied that bugs have stabilized.
I have the same problem. After getting a phone call and answering it on iOS4 the sounds are lost.
This same problem exists (or at least existed before) when coming back from video playback. In my app I worked around it by reinitializing the whole sound system and loading sounds again after video was played.
Hope that this gets fixed. I don’t want to re-initialize every time my application enters background and becomes active again. At least we need a callback so we can re-initialize only after the system gets overtaken by another audio session.
I did playstream example on iOS4 3GS device.
startup is done well but..
follow situation device break down ..
– Lock key press. return application. and "Tic" sound you can hear endless.
– Home Key Press return application. and "Tic" sound you can hear endless.
– Phone Called -> Iphone hold . i do device reset manually
– Alram event -> Iphone hold . i do device reset manually and "Tic" sound you can hear endless.
I use FMOD SDK 4.31.04.
Our next release should solve the problem with AudioQueue codec sounds not coming back after a device lock / unlock or background / foreground cycle.
FMOD_IPhone_RestoreAudioSession should only be called from applicationWillEnterForeground at this stage. The iPhone getting started guide will be updated to reflect proper usage.
mathew, i don’t like another hack in my multiplatform FMOD wrapper, it’s already full of "#ifdef PSP" and "#ifdef APPLE" etc.
please remove this FMOD_IPhone_RestoreAudioSession!
AFAIK you can use NSNotificationCenter to observe application events.
and by the way your solution doesn’t work for me with hardware mp3 streaming. I’m calling this function in applicationWillEnterForeground and applicationDidBecomeActive, but no luck – i can’t hear music after resume.
I’m using v4.32.00
Please login first to submit.