Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone SDK audioSession question

In my app i record and play audio at the same time. The app is almost finished. But there is one thing, that annoying me. When audio session is set to PlayAndRecord, sounds become quiet in comparison with the same sounds with the SoloAmbient category. Is there any way to make sound louder using PlayAndRecord?

like image 510
Morion Avatar asked Oct 23 '09 13:10

Morion


1 Answers

when you use the session for play and record, the playback comes out of the speaker used for the phone, otherwise it comes out the speaker located at the bottom of the phone. this is to prevent feedback. you can override this like so (but watch out for feedback, not an issue if you aren't doing both at once)

    //when the category is play and record the playback comes out of the speaker used for phone conversation to avoid feedback
    //change this to the normal or default speaker

    UInt32 doChangeDefaultRoute = 1;        
    AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof (doChangeDefaultRoute), &doChangeDefaultRoute);

this code works on 3.1.2, earlier sdk's you have to do differently.

    UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; 
    status = AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride);

you have to be careful with this method, it will override even if you have headphones plugged in, you have to monitor interruptions and change the routes accordingly. much better now using 3.1.2

like image 83
Aran Mulholland Avatar answered Oct 09 '22 19:10

Aran Mulholland