I am trying to use the new functions to get an AudioDeviceID from a CFString containing the unique ID of a device.
The code I had before (but which uses the deprecated AudioHardwareGetProperty function still works fine but I'd like to get rid of the compiler warning.
- (AudioDeviceID) deviceWithUniqueID:(NSString *)inUniqueID
{
OSStatus err;
AudioDeviceID audioDeviceID;
UInt32 audioValueTranslationSize = sizeof(AudioValueTranslation);
UInt32 audioDeviceIDSize = sizeof(AudioDeviceID);
AudioValueTranslation value;
value.mInputData = &inUniqueID;
value.mInputDataSize = sizeof(CFStringRef);
value.mOutputData = &audioDeviceID;
value.mOutputDataSize = audioDeviceIDSize;
AudioObjectPropertyAddress theAddress = { kAudioHardwarePropertyDeviceForUID,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster };
audioValueTranslationSize = sizeof(AudioValueTranslation);
audioDeviceIDSize = sizeof(AudioDeviceID);
err = AudioObjectGetPropertyData(kAudioObjectSystemObject, &theAddress, audioValueTranslationSize, &value, &audioDeviceIDSize, &audioDeviceID);
NSLog(@"%i", err);
return audioDeviceID;
}
I always get a !siz error when I ask for the property. Since I couldn't find a single example using a CFString as a qualifier for this method, I could only guess on how to create the AudioValueTranslation record.
Any help would be appreciated.