Created
November 29, 2011 21:34
-
-
Save aranm/1406610 to your computer and use it in GitHub Desktop.
iOS AudioSession Getting all USB Audio Ouputs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* print a CFNumber */ | |
void printCfNumber(CFNumberRef cfNum) { | |
SInt32 s; | |
if(!CFNumberGetValue(cfNum, kCFNumberSInt32Type, &s)) { | |
printf("***CFNumber overflow***"); | |
return; | |
} | |
printf("%d", (int)s); | |
} | |
void GetAudioOutputRoutes(){ | |
//get all available output destination | |
UInt32 size = sizeof(CFArrayRef); | |
CFArrayRef audioOutputRoutes; | |
OSStatus err = AudioSessionGetProperty(kAudioSessionProperty_OutputDestinations, &size, &audioOutputRoutes); | |
if (err == noErr){ | |
CFIndex i, c = CFArrayGetCount(audioOutputRoutes); | |
CFDictionaryRef audioOutput; | |
for (i=0; i<c; i++) { | |
audioOutput = (CFDictionaryRef)CFArrayGetValueAtIndex(audioOutputRoutes, i); | |
CFNumberRef routeId = (CFNumberRef)CFDictionaryGetValue(audioOutput, kAudioSession_OutputDestinationKey_ID); | |
CFStringRef routeDescription = (CFStringRef)CFDictionaryGetValue(audioOutput, kAudioSession_OutputDestinationKey_Description); | |
printCfNumber(routeId); | |
const char *bytes; | |
//haven't worked out how to print out the CFString yet. | |
bytes = CFStringGetCStringPtr(routeDescription, kCFStringEncodingMacRoman); | |
printf(bytes); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment