0
0

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.

Thoughts?

  • You must to post comments
0
0

Thanks for that Mathew,

I will hold out until the next release is out.

Regards

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

Hi Mathew,

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.

Thanks.

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

Yes, using the sessionCategory:

FMOD_IPHONE_SESSIONCATEGORY_PLAYANDRECORD;

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?

  • You must to post comments
0
0

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).

  • You must to post comments
0
0

Hi Mathew,

[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]

  1. 3.5mm stereo Jack is plugged in to the headphones output.
  2. Boot the iPod app and check audio is playing out the jack – yep
  3. Boot my App
  4. Trigger audio cue, or initiate record/playback through custom DSP

Audio comes out of the Speaker, not the jack as expected.

  1. With the app still running and generating audio
  2. 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.

Thoughts?

thanks,

  • You must to post comments
0
0

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.

  • You must to post comments
0
0

Thanks Mathew,

I will look into the AudioToolbox sessionProperties and see if I can get that behaviour. In the case of having to re-apply the override, I would need to stop, then restart FMOD, which is a good 4-6 seconds?

Cheers

  • You must to post comments
0
0

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.

  • You must to post comments
Showing 10 results
Your Answer

Please first to submit.