我正在玩iOS中的AudioSessions,我想使用iphone的内置麦克风作为音频输入路径,即使插入了外接耳机(包括麦克风)。我能够检测到耳机是否插入使用以下代码:
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
那么,任何想法如何做到这一点?