void CAHALAudioSystemObject::LogBasicDeviceInfo() { UInt32 theNumberDevices = GetNumberAudioDevices(); CAAutoArrayDelete<AudioObjectID> theDeviceList(theNumberDevices); GetAudioDevices(theNumberDevices, theDeviceList); DebugMessageN1("CAHALAudioSystemObject::LogBasicDeviceInfo: %d devices", (int)theNumberDevices); for(UInt32 theDeviceIndex = 0; theDeviceIndex < theNumberDevices; ++theDeviceIndex) { char theCString[256]; UInt32 theCStringSize = sizeof(theCString); DebugMessageN1("CAHALAudioSystemObject::LogBasicDeviceInfo: Device %d", (int)theDeviceIndex); CAHALAudioDevice theDevice(theDeviceList[theDeviceIndex]); DebugMessageN1("CAHALAudioSystemObject::LogBasicDeviceInfo: Object ID: %d", (int)theDeviceList[theDeviceIndex]); CACFString theDeviceName(theDevice.CopyName()); theCStringSize = sizeof(theCString); theDeviceName.GetCString(theCString, theCStringSize); DebugMessageN1("CAHALAudioSystemObject::LogBasicDeviceInfo: Name: %s", theCString); CACFString theDeviceUID(theDevice.CopyDeviceUID()); theCStringSize = sizeof(theCString); theDeviceUID.GetCString(theCString, theCStringSize); DebugMessageN1("CAHALAudioSystemObject::LogBasicDeviceInfo: UID: %s", theCString); } }
AudioDeviceID CAAudioHardwareSystem::GetDeviceAtIndex(UInt32 inIndex) { AudioDeviceID theAnswer = 0; UInt32 theNumberDevices = GetNumberDevices(); if((theNumberDevices > 0) && (inIndex < theNumberDevices)) { CAAutoArrayDelete<AudioDeviceID> theDeviceList(theNumberDevices); UInt32 theSize = theNumberDevices * sizeof(AudioDeviceID); GetPropertyData(kAudioHardwarePropertyDevices, theSize, theDeviceList); theAnswer = theDeviceList[inIndex]; } return theAnswer; }
AudioObjectID CAHALAudioSystemObject::GetAudioDeviceAtIndex(UInt32 inIndex) const { AudioObjectID theAnswer = kAudioObjectUnknown; UInt32 theNumberDevices = GetNumberAudioDevices(); if((theNumberDevices > 0) && (inIndex < theNumberDevices)) { CAAutoArrayDelete<AudioObjectID> theDeviceList(theNumberDevices); GetAudioDevices(theNumberDevices, theDeviceList); if((theNumberDevices > 0) && (inIndex < theNumberDevices)) { theAnswer = theDeviceList[inIndex]; } } return theAnswer; }
UInt32 CAAudioHardwareSystem::GetIndexForDevice(const AudioDeviceID inDevice) { UInt32 theAnswer = 0xFFFFFFFF; UInt32 theNumberDevices = GetNumberDevices(); if(theNumberDevices > 0) { CAAutoArrayDelete<AudioDeviceID> theDeviceList(theNumberDevices); UInt32 theSize = theNumberDevices * sizeof(AudioDeviceID); GetPropertyData(kAudioHardwarePropertyDevices, theSize, theDeviceList); for(UInt32 theIndex = 0; theIndex < theNumberDevices; ++theIndex) { if(inDevice == theDeviceList[theIndex]) { theAnswer = theIndex; break; } } } return theAnswer; }