I am playing around AudioSessions in iOS and I want to use the built in mic of the iphone as audio input route even if an external headset (including mic) is plugged in. I'm able to detect if a headset is plugged in using the following code:
CFStringRef route;
UInt32 propertySize = sizeof(CFStringRef);
AudioSessionInitialize(NULL, NULL, NULL, NULL);
AudioSessionGetProperty(kAudioSessionProperty_AudioRoute, &propertySize, &route);
if((route == NULL) || (CFStringGetLength(route) == 0)){
// Silent Mode
NSLog(@"AudioRoute: SILENT");
} else {
NSString* routeStr = (NSString*)route;
NSLog(@"AudioRoute: %@", routeStr);
NSRange headsetRange = [routeStr rangeOfString : @"Headset"];
if(headsetRange.location != NSNotFound) {
NSLog(@"Headset")
//route Audio IN to built-in mic.
}
.... more code
So, any ideas how to do this?