I was trying out Apple's sample app SpeakHere, and wanted to listen through the speakerphone speaker instead of the ear speaker.
I was able to turn on the speakerphone speaker using this code:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
But after that the app will no longer record. It freezes. This code doesn't do any good:
UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;
AudioSessionSetProperty(kAudioSessionProperty_AudioCategory, sizeof(sessionCategory), &sessionCategory);
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_None;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute,sizeof (audioRouteOverride),&audioRouteOverride);
Boy, it sure seems like if you can toggle the speaker on with top code, you ought to be able to toggle it off with the other code. What's the secret?
Are you trying to do this while your Audio Queue is running? Or did you stop the audio queue before and restart it after changing the audio session?
Have you looked at the error return values from all the audio session and audio queue calls to see if an error is being reported? And, if so, what is the error value?