Re: How to use AudioHardwareGetProperty
Re: How to use AudioHardwareGetProperty
- Subject: Re: How to use AudioHardwareGetProperty
- From: David Duncan <email@hidden>
- Date: Thu, 7 Aug 2003 09:57:19 -0400
On Thursday, August 7, 2003, at 05:13 AM, Malcolm Haylock wrote:
As I understand it (by guessing from the "documentation"), both the
input and output are passed by the same pointer outPropertyData.
Therefore to pass the UID and return the AudioDeviceID would be
something like:
CFStringRef uid; // set somewhere else
Ptr outPropertyData=uid;
UInt32 ioPropertyDataSize=sizeof(uid);
OSStatus err=AudioHardwareGetProperty(
kAudioHardwarePropertyDeviceForUID,
&ioPropertyDataSize,
outPropertyData);
AudioDeviceID id=*((AudioDeviceID*) outPropertyData);
From AudioHardware.h kAudioHardwarePropertyDeviceForUID = 'duid',
// retrieves the AudioDeviceID for the given device
// unique identifier previously retrieved with
// kAudioDevicePropertyUID (see below) using an
// AudioValueTranslation structure. The input is a
// CFStringRef containing the UID and the output
// is an AudioDeviceID.
The key here is that they state that they are using an
"AudioValueTranslationStructure" - therefor you need to use one too.
CFStringRef uid;
AudioDeviceID id;
AudioValueTranslation avt = {
&uid, // mInputData
sizeof(uid), // mInputDataSize
&id, // mOutputData
sizeof(id) // mOutputDataSize
};
UInt32 dataSize = sizeof(avt);
OSStatus err=AudioHardwareGetProperty(
kAudioHardwarePropertyDeviceForUID,
&dataSize,
&avt);
After the call to AudioHardwareGetProperty, your AudioDeviceID should
be filled in.
NOTE: All Get/Set property calls (pretty much across the entire OS)
take a *pointer* to their data. So if you are expecting a CFStringRef
back, you need to pass a CFStringRef*, etc. Your example just passed in
the raw CFStringRef and probably would have crashed for your trouble.
--
Reality is what, when you stop believing in it, doesn't go away.
Failure is not an option. It is a privilege reserved for those who try.
David Duncan
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.