46 #include "CAHALAudioSystemObject.h"
49 #include "CAAutoDisposer.h"
50 #include "CAPropertyAddress.h"
56 CAHALAudioSystemObject::CAHALAudioSystemObject()
58 CAHALAudioObject(kAudioObjectSystemObject)
62 CAHALAudioSystemObject::~CAHALAudioSystemObject()
66 UInt32 CAHALAudioSystemObject::GetNumberAudioDevices()
const
68 CAPropertyAddress theAddress(kAudioHardwarePropertyDevices);
69 UInt32 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
70 theAnswer /=
sizeof(AudioObjectID);
74 void CAHALAudioSystemObject::GetAudioDevices(UInt32& ioNumberAudioDevices, AudioObjectID* outAudioDevices)
const
76 CAPropertyAddress theAddress(kAudioHardwarePropertyDevices);
77 UInt32 theSize = ioNumberAudioDevices *
sizeof(AudioObjectID);
78 GetPropertyData(theAddress, 0, NULL, theSize, outAudioDevices);
79 ioNumberAudioDevices = theSize /
sizeof(AudioObjectID);
82 AudioObjectID CAHALAudioSystemObject::GetAudioDeviceAtIndex(UInt32 inIndex)
const
84 AudioObjectID theAnswer = kAudioObjectUnknown;
85 UInt32 theNumberDevices = GetNumberAudioDevices();
86 if((theNumberDevices > 0) && (inIndex < theNumberDevices))
88 CAAutoArrayDelete<AudioObjectID> theDeviceList(theNumberDevices);
89 GetAudioDevices(theNumberDevices, theDeviceList);
90 if((theNumberDevices > 0) && (inIndex < theNumberDevices))
92 theAnswer = theDeviceList[inIndex];
98 AudioObjectID CAHALAudioSystemObject::GetAudioDeviceForUID(CFStringRef inUID)
const
100 AudioObjectID theAnswer = kAudioObjectUnknown;
101 AudioValueTranslation theValue = { &inUID,
sizeof(CFStringRef), &theAnswer,
sizeof(AudioObjectID) };
102 CAPropertyAddress theAddress(kAudioHardwarePropertyDeviceForUID);
103 UInt32 theSize =
sizeof(AudioValueTranslation);
104 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
108 static inline AudioObjectPropertySelector CAHALAudioSystemObject_CalculateDefaultDeviceProperySelector(
bool inIsInput,
bool inIsSystem)
110 AudioObjectPropertySelector theAnswer = kAudioHardwarePropertyDefaultOutputDevice;
113 theAnswer = kAudioHardwarePropertyDefaultInputDevice;
117 theAnswer = kAudioHardwarePropertyDefaultSystemOutputDevice;
122 AudioObjectID CAHALAudioSystemObject::GetDefaultAudioDevice(
bool inIsInput,
bool inIsSystem)
const
124 AudioObjectID theAnswer = kAudioObjectUnknown;
125 CAPropertyAddress theAddress(CAHALAudioSystemObject_CalculateDefaultDeviceProperySelector(inIsInput, inIsSystem));
126 UInt32 theSize =
sizeof(AudioObjectID);
127 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
131 void CAHALAudioSystemObject::SetDefaultAudioDevice(
bool inIsInput,
bool inIsSystem, AudioObjectID inNewDefaultDevice)
133 CAPropertyAddress theAddress(CAHALAudioSystemObject_CalculateDefaultDeviceProperySelector(inIsInput, inIsSystem));
134 UInt32 theSize =
sizeof(AudioObjectID);
135 SetPropertyData(theAddress, 0, NULL, theSize, &inNewDefaultDevice);
138 AudioObjectID CAHALAudioSystemObject::GetAudioPlugInForBundleID(CFStringRef inUID)
const
140 AudioObjectID theAnswer = kAudioObjectUnknown;
141 AudioValueTranslation theValue = { &inUID,
sizeof(CFStringRef), &theAnswer,
sizeof(AudioObjectID) };
142 CAPropertyAddress theAddress(kAudioHardwarePropertyPlugInForBundleID);
143 UInt32 theSize =
sizeof(AudioValueTranslation);
144 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);