IOS: Can i change the audioCategory in real time with FMOD API?

(huzhiyong) #1

I ecountered a problem, can i change the audioCategory in real time? because i found that when I trigger System::recordStart function, then my game’s audiocategory likely be set to FMOD_IPHONE_SESSIONCATEGORY_PLAYANDRECORD internally, which i have set to FMOD_IPHONE_SESSIONCATEGORY_AMBIENTSOUND when FMODSystem::init();

the problem is when I call System::RecordStop(id), system internal not set it back to FMOD_IPHONE_SESSIONCATEGORY_AMBIENTSOUND for me!!! so please somebody who have idea to solve it can provide some advice.

by the way, why i want to keep the FMOD_IPHONE_SESSIONCATEGORY_AMBIENTSOUND setting, because when game running in this mode, the game won’t be stuck a period when coming to froreground. so we strongly require this category not be change after recording!

(Mathew Block) #2

It’s not possible to change the audio category in realtime, you must provide FMOD_IPHONE_SESSIONCATEGORY_AMBIENTSOUND at System::init time via FMOD_IPHONE_EXTRADRIVERDATA::sessionCategory.

When you call System::recordStart FMOD will temporarily switch (internally) to FMOD_IPHONE_SESSIONCATEGORY_PLAYANDRECORD, then at System::recordStop it will switch back to the category provided during System::init.

It sounds like you are doing things correctly, can you link with the logging version and provide the TTY output?

(huzhiyong) #3

I have found out what is the matter about that, If I perform [[AudioSeesion sharedInstanced] setActive:NO error:nil] after I finish System::recordStop(); It do solve my problem!!! the game not stuck any more when com back foreground from backgound… but! this move will cause Channel::Stop() method stuck a long time( hurt the game experience! ), this is another downside i need to figure out how to repair it; may be you can have any idea about this?

(Mathew Block) #4

You shouldn’t call any AudioSession APIs, FMOD will internally do this for you.

(huzhiyong) #5

yeap,i know, after i preform [[AudioSeesion sharedInstanced] setActive:NO error:nil] do have problem, my sound::Play could not play anymore.

but back to my original problem, can FMOD technician do a improvement to it?
you can reproduce this situation by this way:
1.enter the game: set initial sessioncategory with FMOD_IPHONE_SESSIONCATEGORY_AMBIENTSOUND, do not perform any record API, and press Home key and let the game come to background, and then press the app icon to let the game come back to foreground. this is resume the game immediately.

2.afterthat, you call some System::recordStart and System::recordStop() API from FMOD, from now on, if you press Home key and let the game come to background, and then press the app icon to let the game come back to foreground, The Game will stuck for a little time. our team leader beg a fix for this problem and may the game more comfortable to the user;

can you list this to the fix sheet for future change? Thanks alot!

(Mathew Block) #6

I’ve been unable to reproduce the problem you are seeing. For me I perform record start (the log says switching from speaker to receiverAndMic), I perform record stop (the log says switching from receiverAndMic to speaker), I then background the app by pressing home, then I foreground the app by clicking it. The app resumes immediately.

Can you provide example code to demonstrating the problem?