# FMOD initialization and interruptions on iOS/Android

**URL:** <https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831>\
**Category:** FMOD Engine\
**Created:** [June 1, 2020, 9:35am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831 "2020-06-01T09:35:05Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [June 1, 2020, 9:35am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/1 "2020-06-01T09:35:05Z")

</div>

Hi, I’m using version 2.00.08. I have two questions:

1. Can I do fmod system initialization on iOS before I do [[AVAudioSession sharedInstance] setActive:true] first time? Will it fail in such way of initialization If I do setActive call later?
2. Which calls are safe between mixerSuspend() and mixerResume() calls on iOS/Android? There is information in android part of [documentation](https://fmod.com/resources/documentation-api?version=2.0&page=platforms-android.html) that tells: “It is extremely important to ensure no FMOD APIs are called in-between suspend and resume as they run the risk of causing a deadlock.”. But there is no such information in iOS part of documentation. Also I’ve found this forum [thread](https://qa.fmod.com/t/examples-on-handling-ios-avaudiosession-notifications/14244) where you say: “MixerSuspend maintains the internal state by keeping everything alive in memory, any calls made to FMOD during this time will be added to the queue and be processed once MixerResume is called”. As I understand all calls to FMOD API are safe, aren’t they?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 2, 2020, 5:50am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/2 "2020-06-02T05:50:01Z")

</div>

If you don’t activate your audio session your application will use the default audio session (you can read more [here](https://developer.apple.com/documentation/avfoundation/avaudiosession?language=objc)).

For Android, you must not call any FMOD APIs between mixerSuspend and mixerResume, otherwise you risk deadlocking your application. For iOS the warning is less severe, you may call FMOD APIs but it’s recommended you don’t, any Studio API commands issued will be queued, if this keeps happening the queue will expand and expand.

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [June 2, 2020, 6:21am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/3 "2020-06-02T06:21:02Z")

</div>

Thank you for your response. One more thing about first question: is it ok if I try to initialize FMOD when application is inside interruption state? I can not activate session in that time and default session is in inactive state. Is FMOD sensitive to iOS session state at all?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 2, 2020, 6:39am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/4 "2020-06-02T06:39:48Z")

</div>

You won’t be able to initialize FMOD if there is currently an interruption, the phone will have excusive access to the sound device. When you call mixerSuspend, internally we release the audio interface allowing the phone to use it, then mixerResume reacquires it resuming playback.

Are you experiencing a particular issue or are these questions hypothetical?

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [June 2, 2020, 6:51am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/5 "2020-06-02T06:51:54Z")

</div>

I have particular issue. If you start application and call Siri a moment later then you won’t be able to activate session until Siri is active. But all others parts of application will work at the background and will do calls to audio system that is not initialized (I can not influence other parts of app). As I understand I need to make my inner queue of audio calls and put it into fmod only after session activation/FMOD initialization, but it’s not very comfortable. Can FMOD handle such situation?

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [June 2, 2020, 6:56am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/6 "2020-06-02T06:56:17Z")

</div>

Also I want to admit that all this thing with restriction of FMOD call between mixerSuspend/mixerResume is uncomfortable because developer should do inner abstraction of audio calls to handle this period of time.

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 2, 2020, 11:41pm UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/7 "2020-06-02T23:41:40Z")

</div>

The mixerSuspend / mixerResume system was built with the assumption the application would be paused in-between those points. What you describe where the application continues running, perhaps for some time sounds similar to the situation on Windows where you unplug your last sound device and are left with none.

For that case we encourage developers to call setOutput(FMOD\_OUTPUTTYPE\_NOSOUND), which allows all FMOD APIs to continue working without using any audio device. Would something like this work for you?

Currently on iOS you cannot call setOutput after initialization, however we should be able to make that work in a patch. Please share your thoughts.

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [June 3, 2020, 1:37am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/8 "2020-06-03T01:37:40Z")

</div>

1. Should I replace calls of mixerSuspend/mixerResume with calls setOutput FMOD\_OUTPUTTYPE\_NOSOUND/FMOD\_OUTPUTTYPE\_AUTODETECT? Or may be I should add these calls additionaly to mixer calls? Or how should I use it?
2. Do you have any ideas how to handle FMOD initialization in the situation when Siri takes audio session at the start of application? Can I call FMOD initialization in that period of time (may be with setOutput to NOSOUND) or should I wait until Siri finishes work and application gets audio session?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 3, 2020, 4:58am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/9 "2020-06-03T04:58:10Z")

</div>

The idea is you would set FMOD to no-sound if you find yourself initializing in the background and then switch to core-audio when SIRI is done. However for iOS FMOD doesn’t support switching output while running (we would need to add this).

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [June 3, 2020, 5:27am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/10 "2020-06-03T05:27:33Z")

</div>

OK, I understand. Thank you. When you are going to add this?

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [June 3, 2020, 5:52am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/11 "2020-06-03T05:52:57Z")

</div>

I can’t offer any guarantees but I’ve scheduled the task for our 2.00.11 release, ~1 month away.  
It cannot go into 2.00.10 because that is in QA at the moment.

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [August 10, 2020, 1:42am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/12 "2020-08-10T01:42:38Z")

</div>

Hi, are there any news? 2.00.11 version was released but I see nothing about this topic in the version description.

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [August 10, 2020, 2:08am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/13 "2020-08-10T02:08:43Z")

</div>

This change landed in 2.01.03, are you able to upgrade?

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [August 10, 2020, 2:37am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/14 "2020-08-10T02:37:35Z")

</div>

It’s still under early access flag, we are waiting for full release of this version to upgrade.

---

<div class="post-metadata">

**Author:** ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)\
**Post date:** [August 11, 2020, 1:46am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/15 "2020-08-11T01:46:11Z")

</div>

We are hoping our next release 2.01.04 will be the first non-early access release.

---

<div class="post-metadata">

**Author:** ![maksimomelyanchuk](https://avatars.discourse-cdn.com/v4/letter/m/eb8c5e/32.png) [@maksimomelyanchuk](https://qa.fmod.com/u/maksimomelyanchuk)\
**Post date:** [August 26, 2020, 5:08am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/16 "2020-08-26T05:08:07Z")

</div>

I have expirienced another bug with mixer suspend/resume on iOS. Actions on app going to background are:

1. Set master channel group zero volume.
2. Set master channel group on pause.
3. Mixer suspend.  
When app going to foreground I do:
4. Mixer resume
5. Set master channel group pause off.

Bu there is short sound when app have appeared from the background. If I remove mixer operations there isn’t such short sound. Iexperimented with flushCommands but had no effect. On Android and windows it works as expected without short sound.

Fmod version is 2.00.10.

---

<div class="post-metadata">

**Author:** ![tristanjl](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/tristanjl/32/261_2.png) [@tristanjl](https://qa.fmod.com/u/tristanjl)\
**Post date:** [August 26, 2020, 7:06am UTC](https://qa.fmod.com/t/fmod-initialization-and-interruptions-on-ios-android/15831/17 "2020-08-26T07:06:40Z")

</div>

Hi maksimomelyanchuk,

That issue is fixed in 2.00.11/2.01.03, so it will be sorted when you next upgrade.
