Is there a method of forcing audio out the HeadPhone jack on the iphone, or at least querying whether there is a jack plugged into the socket, and thus routing the audio out the iPhone socket and not the speaker.
Have looked trough the FMOD docs and the iPhone FMODiPhone.h file and have not seen a solution.
Specifically my problem is that if I have a 3.5mm jack in the socket, and then launch my app, FMOD doesnt see the jack and thus routes audio out the speaker. If I plug the jack in with the app running, a system event "has plugged jack into socket" must be being sent and FMOD picks this up and then routes the audio out the jack.
- tdc asked 7 years ago
FMOD doesn’t actually control the audio routing, it is a feature of the iPhone OS, we simply output to whatever the OS determines.
There is one exception and that is the case where you are recording and playing at the same time, in that case we can force the audio out either the main speaker or the receiver speaker.
Thanks for that. I have traced the issue to my use of:
extradriverdata.forceSpeakerOutput = true;
Is there a method in FMOD to ask the system whether the AudioToolbox is routing the audio out the headphone jack or the speaker? I need to get FMOD to respond to a jack being plugged in, or removed.
Just to clarify are you using the recording API or setting the record and play category? Otherwise the forceSpeakerOutput flag should have no effect. Also I would have expected forceSpeakerOutput to not apply if headphones are plugged in, but I may be wrong.
There is no feature in FMOD to query where sound is routed since FMOD has very little control over it. I would take a look at the audio session API and use one of those function to query.
Yes, using the sessionCategory:
I will investigate catching the delegate method in the iPhone SDK for changing audio paths and get FMOD to stop and start.
Am I right in thinking that I will have to stop and then restart the FMOD engine to change the extradriverdata.forceSpeakerOutput BOOL?
What behaviour are you trying to achieve?
By default the audio should route as you would expect, if headphones are plugged in audio goes there, if it is unplugged audio goes back to the speaker.
If you wanted to change forceSpeakerOutput at runtime, then yes, you would have to reinit as the value is set via extradriverdata (an init only parameter).
[quote="mathew":qskp00ou]What behaviour are you trying to achieve?[/quote:qskp00ou]
I am trying to get FMOD to see that the headphones are plugged in and route the audio to them. I know FMOD doesnt do the routing, but it seems there is something screwy.
This is what currently happens.
The iPhone App FMOD engine is set to:
[code:qskp00ou]extradriverdata.sessionCategory = FMOD_IPHONE_SESSIONCATEGORY_PLAYANDRECORD;
extradriverdata.forceSpeakerOutput = true;[/code:qskp00ou]
- 3.5mm stereo Jack is plugged in to the headphones output.
- Boot the iPod app and check audio is playing out the jack – yep
- Boot my App
- Trigger audio cue, or initiate record/playback through custom DSP
Audio comes out of the Speaker, not the jack as expected.
- With the app still running and generating audio
- Unplug the jack and then replug it, the audio output from FMOD shifts from the speaker to the headphone jack.
So it seems that the system is only changing the route of the FMOD audio when it receives the "Headphones plugged in" call.
Hmmm, ok I see what you mean, I just tried this out on one of our iPhones.
It looks like the meaning of the override flag has changed, however I am not certain if this is intentional by Apple or a bug.
Previously the override flag would only matter for the device speakers, it would never force headphone output to the device speaker. Now it does, which doesn’t make sense to me.
To keep the original behaviour you would need to set the override flag to false during FMOD init. Then after init query the current audio route with kAudioSessionProperty_AudioRoute, if the route is "receiver and microphone" then do the override with kAudioSessionProperty_OverrideAudioRoute. Then subscribe to route change notifications kAudioSessionProperty_AudioRouteChange and monitor for route changes to "receiver and microphone" and re-apply the override if things have been plugged in and out.
I know, it’s a lot of stuff to do. I have asked on the iPhone developer forums to see if this new behaviour is intented or not, regardless of the outcome I will probably implement the above in FMOD by default if the user sets the override flag in init.
I am actually working on the solution right now, it’s finished, I’m just testing it. The behavior of the override flag for FMOD will be it only changes the preference of "ReceiverAndMicrophone" to "SpeakerAndMicrophone". All other routes will remain correct.
This change will be in our next release which should be out by the end of the week.
But just to answer your question directly, you would not use the FMOD override flag during init, you would use the iPhone API function, which can be used at any time without stopping FMOD.
Please login first to submit.