46 #include "CAHALAudioDevice.h"
49 #include "CAAutoDisposer.h"
50 #include "CADebugMacros.h"
51 #include "CAException.h"
52 #include "CAHALAudioStream.h"
53 #include "CAHALAudioSystemObject.h"
54 #include "CAPropertyAddress.h"
60 CAHALAudioDevice::CAHALAudioDevice(AudioObjectID inAudioDevice)
62 CAHALAudioObject(inAudioDevice)
66 CAHALAudioDevice::CAHALAudioDevice(CFStringRef inUID)
68 CAHALAudioObject(CAHALAudioSystemObject().GetAudioDeviceForUID(inUID))
72 CAHALAudioDevice::~CAHALAudioDevice()
76 CFStringRef CAHALAudioDevice::CopyDeviceUID()
const
78 CAPropertyAddress theAddress(kAudioDevicePropertyDeviceUID);
79 return GetPropertyData_CFString(theAddress, 0, NULL);
82 bool CAHALAudioDevice::HasModelUID()
const
84 CAPropertyAddress theAddress(kAudioDevicePropertyModelUID);
85 return HasProperty(theAddress);
88 CFStringRef CAHALAudioDevice::CopyModelUID()
const
90 CAPropertyAddress theAddress(kAudioDevicePropertyModelUID);
91 return GetPropertyData_CFString(theAddress, 0, NULL);
94 CFStringRef CAHALAudioDevice::CopyConfigurationApplicationBundleID()
const
96 CAPropertyAddress theAddress(kAudioDevicePropertyConfigurationApplication);
97 return GetPropertyData_CFString(theAddress, 0, NULL);
100 CFURLRef CAHALAudioDevice::CopyIconLocation()
const
102 CFURLRef theAnswer = NULL;
103 CAPropertyAddress theAddress(kAudioDevicePropertyIcon);
104 UInt32 theSize =
sizeof(CFURLRef);
105 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
109 UInt32 CAHALAudioDevice::GetTransportType()
const
111 CAPropertyAddress theAddress(kAudioDevicePropertyTransportType);
112 return GetPropertyData_UInt32(theAddress, 0, NULL);
115 bool CAHALAudioDevice::CanBeDefaultDevice(
bool inIsInput,
bool inIsSystem)
const
117 CAPropertyAddress theAddress(inIsSystem ? kAudioDevicePropertyDeviceCanBeDefaultSystemDevice : kAudioDevicePropertyDeviceCanBeDefaultDevice, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
118 return GetPropertyData_UInt32(theAddress, 0, NULL) != 0;
121 bool CAHALAudioDevice::HasDevicePlugInStatus()
const
123 CAPropertyAddress theAddress(kAudioDevicePropertyPlugIn);
124 return HasProperty(theAddress);
127 OSStatus CAHALAudioDevice::GetDevicePlugInStatus()
const
129 CAPropertyAddress theAddress(kAudioDevicePropertyPlugIn);
130 return GetPropertyData_UInt32(theAddress, 0, NULL);
133 bool CAHALAudioDevice::IsAlive()
const
135 CAPropertyAddress theAddress(kAudioDevicePropertyDeviceIsAlive);
136 return GetPropertyData_UInt32(theAddress, 0, NULL) != 0;
139 bool CAHALAudioDevice::IsHidden()
const
141 CAPropertyAddress theAddress(kAudioDevicePropertyIsHidden);
142 return GetPropertyData_UInt32(theAddress, 0, NULL) != 0;
145 pid_t CAHALAudioDevice::GetHogModeOwner()
const
147 pid_t theAnswer = -1;
148 CAPropertyAddress theAddress(kAudioDevicePropertyHogMode);
149 if(HasProperty(theAddress))
151 UInt32 theSize =
sizeof(pid_t);
152 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
157 bool CAHALAudioDevice::IsHogModeSettable()
const
159 bool theAnswer =
false;
160 CAPropertyAddress theAddress(kAudioDevicePropertyHogMode);
161 if(HasProperty(theAddress))
163 theAnswer = IsPropertySettable(theAddress);
168 bool CAHALAudioDevice::TakeHogMode()
170 CAPropertyAddress theAddress(kAudioDevicePropertyHogMode);
171 pid_t thePID = getpid();
172 if(HasProperty(theAddress))
174 SetPropertyData(theAddress, 0, NULL,
sizeof(pid_t), &thePID);
176 return thePID == getpid();
179 void CAHALAudioDevice::ReleaseHogMode()
181 CAPropertyAddress theAddress(kAudioDevicePropertyHogMode);
182 if(HasProperty(theAddress))
185 SetPropertyData(theAddress, 0, NULL,
sizeof(pid_t), &thePID);
189 bool CAHALAudioDevice::HasPreferredStereoChannels(
bool inIsInput)
const
191 CAPropertyAddress theAddress(kAudioDevicePropertyPreferredChannelsForStereo, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
192 return HasProperty(theAddress);
195 void CAHALAudioDevice::GetPreferredStereoChannels(
bool inIsInput, UInt32& outLeft, UInt32& outRight)
const
197 CAPropertyAddress theAddress(kAudioDevicePropertyPreferredChannelsForStereo, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
198 UInt32 theStereoPair[2] = { 0, 0 };
199 UInt32 theSize = 2 *
sizeof(UInt32);
200 GetPropertyData(theAddress, 0, NULL, theSize, theStereoPair);
201 outLeft = theStereoPair[0];
202 outRight = theStereoPair[1];
205 void CAHALAudioDevice::SetPreferredStereoChannels(
bool inIsInput, UInt32 inLeft, UInt32 inRight)
207 CAPropertyAddress theAddress(kAudioDevicePropertyPreferredChannelsForStereo, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
208 UInt32 theStereoPair[2] = { inLeft, inRight };
209 SetPropertyData(theAddress, 0, NULL, 2 *
sizeof(UInt32), theStereoPair);
212 bool CAHALAudioDevice::HasPreferredChannelLayout(
bool inIsInput)
const
214 CAPropertyAddress theAddress(kAudioDevicePropertyPreferredChannelLayout, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
215 return HasProperty(theAddress);
218 void CAHALAudioDevice::GetPreferredChannelLayout(
bool inIsInput, AudioChannelLayout& outChannelLayout)
const
220 CAPropertyAddress theAddress(kAudioDevicePropertyPreferredChannelLayout, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
221 UInt32 theSize = OffsetOf32(AudioChannelLayout, mChannelDescriptions) + GetTotalNumberChannels(inIsInput) * SizeOf32(AudioChannelDescription);
222 GetPropertyData(theAddress, 0, NULL, theSize, &outChannelLayout);
225 void CAHALAudioDevice::SetPreferredStereoChannels(
bool inIsInput, AudioChannelLayout& inChannelLayout)
227 CAPropertyAddress theAddress(kAudioDevicePropertyPreferredChannelLayout, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
228 UInt32 theSize = OffsetOf32(AudioChannelLayout, mChannelDescriptions) + GetTotalNumberChannels(inIsInput) * SizeOf32(AudioChannelDescription);
229 SetPropertyData(theAddress, 0, NULL, theSize, &inChannelLayout);
232 UInt32 CAHALAudioDevice::GetNumberRelatedAudioDevices()
const
234 CAPropertyAddress theAddress(kAudioDevicePropertyRelatedDevices);
235 UInt32 theAnswer = 0;
236 if(HasProperty(theAddress))
238 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
239 theAnswer /=
sizeof(AudioObjectID);
244 void CAHALAudioDevice::GetRelatedAudioDevices(UInt32& ioNumberRelatedDevices, AudioObjectID* outRelatedDevices)
const
246 CAPropertyAddress theAddress(kAudioDevicePropertyRelatedDevices);
247 if(HasProperty(theAddress))
249 UInt32 theSize = ioNumberRelatedDevices *
sizeof(AudioObjectID);
250 GetPropertyData(theAddress, 0, NULL, theSize, outRelatedDevices);
251 ioNumberRelatedDevices = theSize /
sizeof(AudioObjectID);
255 UInt32 theSize = ioNumberRelatedDevices *
sizeof(AudioObjectID);
256 memset(outRelatedDevices, 0, theSize);
257 ioNumberRelatedDevices = 0;
261 AudioObjectID CAHALAudioDevice::GetRelatedAudioDeviceByIndex(UInt32 inIndex)
const
263 AudioObjectID theAnswer = kAudioObjectUnknown;
264 UInt32 theNumberRelatedDevices = GetNumberRelatedAudioDevices();
265 if((theNumberRelatedDevices > 0) && (inIndex < theNumberRelatedDevices))
267 CAAutoArrayDelete<AudioObjectID> theRelatedDeviceList(theNumberRelatedDevices);
268 GetRelatedAudioDevices(theNumberRelatedDevices, theRelatedDeviceList);
269 if((theNumberRelatedDevices > 0) && (inIndex < theNumberRelatedDevices))
271 theAnswer = theRelatedDeviceList[inIndex];
277 UInt32 CAHALAudioDevice::GetNumberStreams(
bool inIsInput)
const
279 CAPropertyAddress theAddress(kAudioDevicePropertyStreams, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
280 UInt32 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
281 theAnswer /=
sizeof(AudioObjectID);
285 void CAHALAudioDevice::GetStreams(
bool inIsInput, UInt32& ioNumberStreams, AudioObjectID* outStreamList)
const
287 CAPropertyAddress theAddress(kAudioDevicePropertyStreams, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
288 UInt32 theSize = ioNumberStreams *
sizeof(AudioObjectID);
289 GetPropertyData(theAddress, 0, NULL, theSize, outStreamList);
290 ioNumberStreams = theSize /
sizeof(AudioObjectID);
293 AudioObjectID CAHALAudioDevice::GetStreamByIndex(
bool inIsInput, UInt32 inIndex)
const
295 AudioObjectID theAnswer = kAudioObjectUnknown;
296 UInt32 theNumberStreams = GetNumberStreams(inIsInput);
297 if((theNumberStreams > 0) && (inIndex < theNumberStreams))
299 CAAutoArrayDelete<AudioObjectID> theStreamList(theNumberStreams);
300 GetStreams(inIsInput, theNumberStreams, theStreamList);
301 if((theNumberStreams > 0) && (inIndex < theNumberStreams))
303 theAnswer = theStreamList[inIndex];
309 UInt32 CAHALAudioDevice::GetTotalNumberChannels(
bool inIsInput)
const
311 UInt32 theAnswer = 0;
312 CAPropertyAddress theAddress(kAudioDevicePropertyStreamConfiguration, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
313 UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
314 CAAutoFree<AudioBufferList> theBufferList(theSize);
315 GetPropertyData(theAddress, 0, NULL, theSize, theBufferList);
316 for(UInt32 theIndex = 0; theIndex < theBufferList->mNumberBuffers; ++theIndex)
318 theAnswer += theBufferList->mBuffers[theIndex].mNumberChannels;
323 void CAHALAudioDevice::GetCurrentVirtualFormats(
bool inIsInput, UInt32& ioNumberStreams, AudioStreamBasicDescription* outFormats)
const
325 ioNumberStreams = std::min(ioNumberStreams, GetNumberStreams(inIsInput));
326 for(UInt32 theIndex = 0; theIndex < ioNumberStreams; ++theIndex)
328 CAHALAudioStream theStream(GetStreamByIndex(inIsInput, theIndex));
329 theStream.GetCurrentVirtualFormat(outFormats[theIndex]);
333 void CAHALAudioDevice::GetCurrentPhysicalFormats(
bool inIsInput, UInt32& ioNumberStreams, AudioStreamBasicDescription* outFormats)
const
335 ioNumberStreams = std::min(ioNumberStreams, GetNumberStreams(inIsInput));
336 for(UInt32 theIndex = 0; theIndex < ioNumberStreams; ++theIndex)
338 CAHALAudioStream theStream(GetStreamByIndex(inIsInput, theIndex));
339 theStream.GetCurrentPhysicalFormat(outFormats[theIndex]);
343 bool CAHALAudioDevice::IsRunning()
const
345 CAPropertyAddress theAddress(kAudioDevicePropertyDeviceIsRunning);
346 UInt32 theAnswer = GetPropertyData_UInt32(theAddress, 0, NULL);
347 return theAnswer != 0;
350 bool CAHALAudioDevice::IsRunningSomewhere()
const
352 CAPropertyAddress theAddress(kAudioDevicePropertyDeviceIsRunningSomewhere);
353 UInt32 theAnswer = 0;
354 if(HasProperty(theAddress))
356 theAnswer = GetPropertyData_UInt32(theAddress, 0, NULL);
358 return theAnswer != 0;
361 UInt32 CAHALAudioDevice::GetLatency(
bool inIsInput)
const
363 CAPropertyAddress theAddress(kAudioDevicePropertyLatency, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
364 return GetPropertyData_UInt32(theAddress, 0, NULL);
367 UInt32 CAHALAudioDevice::GetSafetyOffset(
bool inIsInput)
const
369 CAPropertyAddress theAddress(kAudioDevicePropertySafetyOffset, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
370 return GetPropertyData_UInt32(theAddress, 0, NULL);
373 bool CAHALAudioDevice::HasClockDomain()
const
375 CAPropertyAddress theAddress(kAudioDevicePropertyClockDomain);
376 return HasProperty(theAddress);
379 UInt32 CAHALAudioDevice::GetClockDomain()
const
381 CAPropertyAddress theAddress(kAudioDevicePropertyClockDomain);
382 return GetPropertyData_UInt32(theAddress, 0, NULL);
385 Float64 CAHALAudioDevice::GetActualSampleRate()
const
387 Float64 theAnswer = 0;
388 CAPropertyAddress theAddress(kAudioDevicePropertyActualSampleRate);
389 if(HasProperty(theAddress))
391 UInt32 theSize =
sizeof(Float64);
392 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
396 theAnswer = GetNominalSampleRate();
401 Float64 CAHALAudioDevice::GetNominalSampleRate()
const
403 Float64 theAnswer = 0;
404 CAPropertyAddress theAddress(kAudioDevicePropertyNominalSampleRate);
405 UInt32 theSize =
sizeof(Float64);
406 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
410 void CAHALAudioDevice::SetNominalSampleRate(Float64 inSampleRate)
412 CAPropertyAddress theAddress(kAudioDevicePropertyNominalSampleRate);
413 SetPropertyData(theAddress, 0, NULL,
sizeof(Float64), &inSampleRate);
416 UInt32 CAHALAudioDevice::GetNumberAvailableNominalSampleRateRanges()
const
418 UInt32 theAnswer = 0;
419 CAPropertyAddress theAddress(kAudioDevicePropertyAvailableNominalSampleRates);
420 if(HasProperty(theAddress))
422 UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
423 theAnswer = theSize /
sizeof(AudioValueRange);
428 void CAHALAudioDevice::GetAvailableNominalSampleRateRanges(UInt32& ioNumberRanges, AudioValueRange* outRanges)
const
430 CAPropertyAddress theAddress(kAudioDevicePropertyAvailableNominalSampleRates);
431 if(HasProperty(theAddress))
433 UInt32 theSize = ioNumberRanges *
sizeof(AudioValueRange);
434 GetPropertyData(theAddress, 0, NULL, theSize, outRanges);
435 ioNumberRanges = theSize /
sizeof(AudioValueRange);
443 void CAHALAudioDevice::GetAvailableNominalSampleRateRangeByIndex(UInt32 inIndex, Float64& outMinimum, Float64& outMaximum)
const
445 UInt32 theNumberRanges = GetNumberAvailableNominalSampleRateRanges();
446 ThrowIf(inIndex >= theNumberRanges, CAException(kAudioHardwareIllegalOperationError),
"CAHALAudioDevice::GetAvailableNominalSampleRateRangeByIndex: index out of range");
447 CAAutoArrayDelete<AudioValueRange> theRanges(theNumberRanges);
448 GetAvailableNominalSampleRateRanges(theNumberRanges, theRanges);
449 outMinimum = theRanges[inIndex].mMinimum;
450 outMaximum = theRanges[inIndex].mMaximum;
453 bool CAHALAudioDevice::IsValidNominalSampleRate(Float64 inSampleRate)
const
455 bool theAnswer =
false;
456 UInt32 theNumberRanges = GetNumberAvailableNominalSampleRateRanges();
457 CAAutoArrayDelete<AudioValueRange> theRanges(theNumberRanges);
458 GetAvailableNominalSampleRateRanges(theNumberRanges, theRanges);
459 for(UInt32 theIndex = 0; !theAnswer && (theIndex < theNumberRanges); ++theIndex)
461 theAnswer = (inSampleRate >= theRanges[theIndex].mMinimum) && (inSampleRate <= theRanges[theIndex].mMinimum);
466 bool CAHALAudioDevice::IsIOBufferSizeSettable()
const
468 CAPropertyAddress theAddress(kAudioDevicePropertyBufferFrameSize);
469 return IsPropertySettable(theAddress);
472 UInt32 CAHALAudioDevice::GetIOBufferSize()
const
474 CAPropertyAddress theAddress(kAudioDevicePropertyBufferFrameSize);
475 return GetPropertyData_UInt32(theAddress, 0, NULL);
478 void CAHALAudioDevice::SetIOBufferSize(UInt32 inBufferSize)
480 CAPropertyAddress theAddress(kAudioDevicePropertyBufferFrameSize);
481 SetPropertyData(theAddress, 0, NULL,
sizeof(UInt32), &inBufferSize);
484 bool CAHALAudioDevice::UsesVariableIOBufferSizes()
const
486 CAPropertyAddress theAddress(kAudioDevicePropertyUsesVariableBufferFrameSizes);
487 return HasProperty(theAddress);
490 UInt32 CAHALAudioDevice::GetMaximumVariableIOBufferSize()
const
492 CAPropertyAddress theAddress(kAudioDevicePropertyUsesVariableBufferFrameSizes);
493 return GetPropertyData_UInt32(theAddress, 0, NULL);
496 bool CAHALAudioDevice::HasIOBufferSizeRange()
const
498 CAPropertyAddress theAddress(kAudioDevicePropertyBufferFrameSizeRange);
499 return HasProperty(theAddress);
502 void CAHALAudioDevice::GetIOBufferSizeRange(UInt32& outMinimum, UInt32& outMaximum)
const
504 AudioValueRange theAnswer = { 0, 0 };
505 CAPropertyAddress theAddress(kAudioDevicePropertyBufferFrameSizeRange);
506 UInt32 theSize =
sizeof(AudioValueRange);
507 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
508 outMinimum =
static_cast<UInt32
>(theAnswer.mMinimum);
509 outMaximum =
static_cast<UInt32
>(theAnswer.mMaximum);
512 AudioDeviceIOProcID CAHALAudioDevice::CreateIOProcID(AudioDeviceIOProc inIOProc,
void* inClientData)
514 AudioDeviceIOProcID theAnswer = NULL;
515 OSStatus theError = AudioDeviceCreateIOProcID(mObjectID, inIOProc, inClientData, &theAnswer);
516 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::CreateIOProcID: got an error creating the IOProc ID");
520 void CAHALAudioDevice::DestroyIOProcID(AudioDeviceIOProcID inIOProcID)
522 OSStatus theError = AudioDeviceDestroyIOProcID(mObjectID, inIOProcID);
523 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::DestroyIOProcID: got an error destroying the IOProc ID");
526 void CAHALAudioDevice::StartIOProc(AudioDeviceIOProcID inIOProcID)
528 OSStatus theError = AudioDeviceStart(mObjectID, inIOProcID);
529 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::StartIOProc: got an error starting an IOProc");
532 void CAHALAudioDevice::StartIOProcAtTime(AudioDeviceIOProcID inIOProcID, AudioTimeStamp& ioStartTime,
bool inIsInput,
bool inIgnoreHardware)
537 theFlags |= kAudioDeviceStartTimeIsInputFlag;
541 theFlags |= kAudioDeviceStartTimeDontConsultDeviceFlag;
544 OSStatus theError = AudioDeviceStartAtTime(mObjectID, inIOProcID, &ioStartTime, theFlags);
545 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::StartIOProcAtTime: got an error starting an IOProc");
548 void CAHALAudioDevice::StopIOProc(AudioDeviceIOProcID inIOProcID)
550 OSStatus theError = AudioDeviceStop(mObjectID, inIOProcID);
551 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::StopIOProc: got an error stopping an IOProc");
554 void CAHALAudioDevice::GetIOProcStreamUsage(AudioDeviceIOProcID inIOProcID,
bool inIsInput,
bool* outStreamUsage)
const
557 UInt32 theNumberStreams = GetNumberStreams(inIsInput);
558 UInt32 theSize =
sizeof(
void*) +
sizeof(UInt32) + (theNumberStreams *
sizeof(UInt32));
559 CAAutoFree<AudioHardwareIOProcStreamUsage> theStreamUsage(theSize);
562 theStreamUsage->mIOProc =
reinterpret_cast<void*
>(inIOProcID);
563 theStreamUsage->mNumberStreams = theNumberStreams;
566 CAPropertyAddress theAddress(kAudioDevicePropertyIOProcStreamUsage, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
567 GetPropertyData(theAddress, 0, NULL, theSize, theStreamUsage);
570 for(UInt32 theIndex = 0; theIndex < theNumberStreams; ++theIndex)
572 outStreamUsage[theIndex] = (theStreamUsage->mStreamIsOn[theIndex] != 0);
576 void CAHALAudioDevice::SetIOProcStreamUsage(AudioDeviceIOProcID inIOProcID,
bool inIsInput,
const bool* inStreamUsage)
579 UInt32 theNumberStreams = GetNumberStreams(inIsInput);
580 UInt32 theSize =
sizeof(
void*) +
sizeof(UInt32) + (theNumberStreams *
sizeof(UInt32));
581 CAAutoFree<AudioHardwareIOProcStreamUsage> theStreamUsage(theSize);
584 theStreamUsage->mIOProc =
reinterpret_cast<void*
>(inIOProcID);
585 theStreamUsage->mNumberStreams = theNumberStreams;
586 for(UInt32 theIndex = 0; theIndex < theNumberStreams; ++theIndex)
588 theStreamUsage->mStreamIsOn[theIndex] = (inStreamUsage[theIndex] ? 1 : 0);
592 CAPropertyAddress theAddress(kAudioDevicePropertyIOProcStreamUsage, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
593 SetPropertyData(theAddress, 0, NULL, theSize, theStreamUsage);
596 Float32 CAHALAudioDevice::GetIOCycleUsage()
const
598 Float32 theAnswer = 0;
599 CAPropertyAddress theAddress(kAudioDevicePropertyIOCycleUsage);
600 UInt32 theSize =
sizeof(Float32);
601 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
605 void CAHALAudioDevice::SetIOCycleUsage(Float32 inValue)
607 CAPropertyAddress theAddress(kAudioDevicePropertyIOCycleUsage);
608 SetPropertyData(theAddress, 0, NULL,
sizeof(Float32), &inValue);
611 void CAHALAudioDevice::GetCurrentTime(AudioTimeStamp& outTime)
613 OSStatus theError = AudioDeviceGetCurrentTime(mObjectID, &outTime);
614 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::GetCurrentTime: got an error getting the current time");
617 void CAHALAudioDevice::TranslateTime(
const AudioTimeStamp& inTime, AudioTimeStamp& outTime)
619 OSStatus theError = AudioDeviceTranslateTime(mObjectID, &inTime, &outTime);
620 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::TranslateTime: got an error translating time");
623 void CAHALAudioDevice::GetNearestStartTime(AudioTimeStamp& ioTime,
bool inIsInput,
bool inIgnoreHardware)
628 theFlags |= kAudioDeviceStartTimeIsInputFlag;
632 theFlags |= kAudioDeviceStartTimeDontConsultDeviceFlag;
635 OSStatus theError = AudioDeviceGetNearestStartTime(mObjectID, &ioTime, theFlags);
636 ThrowIfError(theError, CAException(theError),
"CAHALAudioDevice::GetNearestStartTime: got an error getting the start time");
639 bool CAHALAudioDevice::HasVolumeControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
641 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeScalar, inScope, inChannel);
642 return HasProperty(theAddress);
645 bool CAHALAudioDevice::VolumeControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
647 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeScalar, inScope, inChannel);
648 return IsPropertySettable(theAddress);
651 Float32 CAHALAudioDevice::GetVolumeControlScalarValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
653 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeScalar, inScope, inChannel);
654 Float32 theValue = 0.0f;
655 UInt32 theSize =
sizeof(Float32);
656 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
660 Float32 CAHALAudioDevice::GetVolumeControlDecibelValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
662 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeDecibels, inScope, inChannel);
663 Float32 theValue = 0.0f;
664 UInt32 theSize =
sizeof(Float32);
665 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
669 void CAHALAudioDevice::SetVolumeControlScalarValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
671 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeScalar, inScope, inChannel);
672 SetPropertyData(theAddress, 0, NULL,
sizeof(Float32), &inValue);
675 void CAHALAudioDevice::SetVolumeControlDecibelValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
677 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeDecibels, inScope, inChannel);
678 SetPropertyData(theAddress, 0, NULL,
sizeof(Float32), &inValue);
681 Float32 CAHALAudioDevice::GetVolumeControlScalarForDecibelValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
const
683 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeDecibelsToScalar, inScope, inChannel);
684 Float32 theValue = inValue;
685 UInt32 theSize =
sizeof(Float32);
686 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
690 Float32 CAHALAudioDevice::GetVolumeControlDecibelForScalarValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
const
692 CAPropertyAddress theAddress(kAudioDevicePropertyVolumeScalarToDecibels, inScope, inChannel);
693 Float32 theValue = inValue;
694 UInt32 theSize =
sizeof(Float32);
695 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
699 bool CAHALAudioDevice::HasSubVolumeControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
701 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeScalar, inScope, inChannel);
702 return HasProperty(theAddress);
705 bool CAHALAudioDevice::SubVolumeControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
707 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeScalar, inScope, inChannel);
708 return IsPropertySettable(theAddress);
711 Float32 CAHALAudioDevice::GetSubVolumeControlScalarValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
713 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeScalar, inScope, inChannel);
714 Float32 theValue = 0.0f;
715 UInt32 theSize =
sizeof(Float32);
716 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
720 Float32 CAHALAudioDevice::GetSubVolumeControlDecibelValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
722 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeDecibels, inScope, inChannel);
723 Float32 theValue = 0.0f;
724 UInt32 theSize =
sizeof(Float32);
725 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
729 void CAHALAudioDevice::SetSubVolumeControlScalarValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
731 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeScalar, inScope, inChannel);
732 SetPropertyData(theAddress, 0, NULL,
sizeof(Float32), &inValue);
735 void CAHALAudioDevice::SetSubVolumeControlDecibelValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
737 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeDecibels, inScope, inChannel);
738 SetPropertyData(theAddress, 0, NULL,
sizeof(Float32), &inValue);
741 Float32 CAHALAudioDevice::GetSubVolumeControlScalarForDecibelValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
const
743 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeDecibelsToScalar, inScope, inChannel);
744 Float32 theValue = inValue;
745 UInt32 theSize =
sizeof(Float32);
746 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
750 Float32 CAHALAudioDevice::GetSubVolumeControlDecibelForScalarValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
const
752 CAPropertyAddress theAddress(kAudioDevicePropertySubVolumeScalarToDecibels, inScope, inChannel);
753 Float32 theValue = inValue;
754 UInt32 theSize =
sizeof(Float32);
755 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
759 bool CAHALAudioDevice::HasMuteControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
761 CAPropertyAddress theAddress(kAudioDevicePropertyMute, inScope, inChannel);
762 return HasProperty(theAddress);
765 bool CAHALAudioDevice::MuteControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
767 CAPropertyAddress theAddress(kAudioDevicePropertyMute, inScope, inChannel);
768 return IsPropertySettable(theAddress);
771 bool CAHALAudioDevice::GetMuteControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
773 CAPropertyAddress theAddress(kAudioDevicePropertyMute, inScope, inChannel);
775 UInt32 theSize =
sizeof(UInt32);
776 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
777 return theValue != 0;
780 void CAHALAudioDevice::SetMuteControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel,
bool inValue)
782 CAPropertyAddress theAddress(kAudioDevicePropertyMute, inScope, inChannel);
783 UInt32 theValue = (inValue ? 1 : 0);
784 UInt32 theSize =
sizeof(UInt32);
785 SetPropertyData(theAddress, 0, NULL, theSize, &theValue);
788 bool CAHALAudioDevice::HasSoloControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
790 CAPropertyAddress theAddress(kAudioDevicePropertySolo, inScope, inChannel);
791 return HasProperty(theAddress);
794 bool CAHALAudioDevice::SoloControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
796 CAPropertyAddress theAddress(kAudioDevicePropertySolo, inScope, inChannel);
797 return IsPropertySettable(theAddress);
800 bool CAHALAudioDevice::GetSoloControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
802 CAPropertyAddress theAddress(kAudioDevicePropertySolo, inScope, inChannel);
804 UInt32 theSize =
sizeof(UInt32);
805 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
806 return theValue != 0;
809 void CAHALAudioDevice::SetSoloControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel,
bool inValue)
811 CAPropertyAddress theAddress(kAudioDevicePropertySolo, inScope, inChannel);
812 UInt32 theValue = (inValue ? 1 : 0);
813 UInt32 theSize =
sizeof(UInt32);
814 SetPropertyData(theAddress, 0, NULL, theSize, &theValue);
817 bool CAHALAudioDevice::HasStereoPanControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
819 CAPropertyAddress theAddress(kAudioDevicePropertyStereoPan, inScope, inChannel);
820 return HasProperty(theAddress);
823 bool CAHALAudioDevice::StereoPanControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
825 CAPropertyAddress theAddress(kAudioDevicePropertyStereoPan, inScope, inChannel);
826 return IsPropertySettable(theAddress);
829 Float32 CAHALAudioDevice::GetStereoPanControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
831 CAPropertyAddress theAddress(kAudioDevicePropertyStereoPan, inScope, inChannel);
832 Float32 theValue = 0.0f;
833 UInt32 theSize =
sizeof(Float32);
834 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
838 void CAHALAudioDevice::SetStereoPanControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel, Float32 inValue)
840 CAPropertyAddress theAddress(kAudioDevicePropertyStereoPan, inScope, inChannel);
841 UInt32 theSize =
sizeof(Float32);
842 SetPropertyData(theAddress, 0, NULL, theSize, &inValue);
845 void CAHALAudioDevice::GetStereoPanControlChannels(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32& outLeftChannel, UInt32& outRightChannel)
const
847 CAPropertyAddress theAddress(kAudioDevicePropertyStereoPan, inScope, inChannel);
848 UInt32 theValue[2] = { 0, 0 };
849 UInt32 theSize = 2 *
sizeof(UInt32);
850 GetPropertyData(theAddress, 0, NULL, theSize, theValue);
851 outLeftChannel = theValue[0];
852 outRightChannel = theValue[1];
855 bool CAHALAudioDevice::HasJackControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
857 CAPropertyAddress theAddress(kAudioDevicePropertyJackIsConnected, inScope, inChannel);
858 return HasProperty(theAddress);
861 bool CAHALAudioDevice::GetJackControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
863 CAPropertyAddress theAddress(kAudioDevicePropertyJackIsConnected, inScope, inChannel);
865 UInt32 theSize =
sizeof(UInt32);
866 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
867 return theValue != 0;
870 bool CAHALAudioDevice::HasSubMuteControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
872 CAPropertyAddress theAddress(kAudioDevicePropertySubMute, inScope, inChannel);
873 return HasProperty(theAddress);
876 bool CAHALAudioDevice::SubMuteControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
878 CAPropertyAddress theAddress(kAudioDevicePropertySubMute, inScope, inChannel);
879 return IsPropertySettable(theAddress);
882 bool CAHALAudioDevice::GetSubMuteControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
884 CAPropertyAddress theAddress(kAudioDevicePropertySubMute, inScope, inChannel);
886 UInt32 theSize =
sizeof(UInt32);
887 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
888 return theValue != 0;
891 void CAHALAudioDevice::SetSubMuteControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel,
bool inValue)
893 CAPropertyAddress theAddress(kAudioDevicePropertySubMute, inScope, inChannel);
894 UInt32 theValue = (inValue ? 1 : 0);
895 UInt32 theSize =
sizeof(UInt32);
896 SetPropertyData(theAddress, 0, NULL, theSize, &theValue);
899 bool CAHALAudioDevice::HasiSubOwnerControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
901 CAPropertyAddress theAddress(kAudioDevicePropertyDriverShouldOwniSub, inScope, inChannel);
902 return HasProperty(theAddress);
905 bool CAHALAudioDevice::iSubOwnerControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
907 CAPropertyAddress theAddress(kAudioDevicePropertyDriverShouldOwniSub, inScope, inChannel);
908 return IsPropertySettable(theAddress);
911 bool CAHALAudioDevice::GetiSubOwnerControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
913 CAPropertyAddress theAddress(kAudioDevicePropertyDriverShouldOwniSub, inScope, inChannel);
915 UInt32 theSize =
sizeof(UInt32);
916 GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
917 return theValue != 0;
920 void CAHALAudioDevice::SetiSubOwnerControlValue(AudioObjectPropertyScope inScope, UInt32 inChannel,
bool inValue)
922 CAPropertyAddress theAddress(kAudioDevicePropertyDriverShouldOwniSub, inScope, inChannel);
923 UInt32 theValue = (inValue ? 1 : 0);
924 UInt32 theSize =
sizeof(UInt32);
925 SetPropertyData(theAddress, 0, NULL, theSize, &theValue);
928 bool CAHALAudioDevice::HasDataSourceControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
930 CAPropertyAddress theAddress(kAudioDevicePropertyDataSource, inScope, inChannel);
931 return HasProperty(theAddress);
934 bool CAHALAudioDevice::DataSourceControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
936 CAPropertyAddress theAddress(kAudioDevicePropertyDataSource, inScope, inChannel);
937 return IsPropertySettable(theAddress);
940 UInt32 CAHALAudioDevice::GetCurrentDataSourceID(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
942 CAPropertyAddress theAddress(kAudioDevicePropertyDataSource, inScope, inChannel);
943 UInt32 theAnswer = 0;
944 UInt32 theSize =
sizeof(UInt32);
945 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
949 void CAHALAudioDevice::SetCurrentDataSourceByID(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32 inID)
951 CAPropertyAddress theAddress(kAudioDevicePropertyDataSource, inScope, inChannel);
952 UInt32 theSize =
sizeof(UInt32);
953 SetPropertyData(theAddress, 0, NULL, theSize, &inID);
956 UInt32 CAHALAudioDevice::GetNumberAvailableDataSources(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
958 CAPropertyAddress theAddress(kAudioDevicePropertyDataSources, inScope, inChannel);
959 UInt32 theAnswer = 0;
960 if(HasProperty(theAddress))
962 UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
963 theAnswer = theSize /
sizeof(UInt32);
968 void CAHALAudioDevice::GetAvailableDataSources(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32& ioNumberSources, UInt32* outSources)
const
970 CAPropertyAddress theAddress(kAudioDevicePropertyDataSources, inScope, inChannel);
971 UInt32 theNumberSources = std::min(GetNumberAvailableDataSources(inScope, inChannel), ioNumberSources);
972 UInt32 theSize = theNumberSources *
sizeof(UInt32);
973 GetPropertyData(theAddress, 0, NULL, theSize, outSources);
974 ioNumberSources = theSize /
sizeof(UInt32);
977 UInt32 CAHALAudioDevice::GetAvailableDataSourceByIndex(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32 inIndex)
const
979 AudioStreamID theAnswer = 0;
980 UInt32 theNumberSources = GetNumberAvailableDataSources(inScope, inChannel);
981 if((theNumberSources > 0) && (inIndex < theNumberSources))
983 CAAutoArrayDelete<UInt32> theSourceList(theNumberSources);
984 GetAvailableDataSources(inScope, inChannel, theNumberSources, theSourceList);
985 theAnswer = theSourceList[inIndex];
990 CFStringRef CAHALAudioDevice::CopyDataSourceNameForID(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32 inID)
const
992 CAPropertyAddress theAddress(kAudioDevicePropertyDataSourceNameForIDCFString, inScope, inChannel);
993 CFStringRef theAnswer = NULL;
994 AudioValueTranslation theTranslation = { &inID,
sizeof(UInt32), &theAnswer,
sizeof(CFStringRef) };
995 UInt32 theSize =
sizeof(AudioValueTranslation);
996 GetPropertyData(theAddress, 0, NULL, theSize, &theTranslation);
1000 bool CAHALAudioDevice::HasDataDestinationControl(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
1002 CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestination, inScope, inChannel);
1003 return HasProperty(theAddress);
1006 bool CAHALAudioDevice::DataDestinationControlIsSettable(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
1008 CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestination, inScope, inChannel);
1009 return IsPropertySettable(theAddress);
1012 UInt32 CAHALAudioDevice::GetCurrentDataDestinationID(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
1014 CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestination, inScope, inChannel);
1015 UInt32 theAnswer = 0;
1016 UInt32 theSize =
sizeof(UInt32);
1017 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
1021 void CAHALAudioDevice::SetCurrentDataDestinationByID(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32 inID)
1023 CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestination, inScope, inChannel);
1024 UInt32 theSize =
sizeof(UInt32);
1025 SetPropertyData(theAddress, 0, NULL, theSize, &inID);
1028 UInt32 CAHALAudioDevice::GetNumberAvailableDataDestinations(AudioObjectPropertyScope inScope, UInt32 inChannel)
const
1030 CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestinations, inScope, inChannel);
1031 UInt32 theAnswer = 0;
1032 if(HasProperty(theAddress))
1034 UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
1035 theAnswer = theSize /
sizeof(UInt32);
1040 void CAHALAudioDevice::GetAvailableDataDestinations(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32& ioNumberDestinations, UInt32* outDestinations)
const
1042 CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestinations, inScope, inChannel);
1043 UInt32 theNumberDestinations = std::min(GetNumberAvailableDataDestinations(inScope, inChannel), ioNumberDestinations);
1044 UInt32 theSize = theNumberDestinations *
sizeof(UInt32);
1045 GetPropertyData(theAddress, 0, NULL, theSize, outDestinations);
1046 ioNumberDestinations = theSize /
sizeof(UInt32);
1049 UInt32 CAHALAudioDevice::GetAvailableDataDestinationByIndex(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32 inIndex)
const
1051 AudioStreamID theAnswer = 0;
1052 UInt32 theNumberDestinations = GetNumberAvailableDataDestinations(inScope, inChannel);
1053 if((theNumberDestinations > 0) && (inIndex < theNumberDestinations))
1055 CAAutoArrayDelete<UInt32> theDestinationList(theNumberDestinations);
1056 GetAvailableDataDestinations(inScope, inChannel, theNumberDestinations, theDestinationList);
1057 theAnswer = theDestinationList[inIndex];
1062 CFStringRef CAHALAudioDevice::CopyDataDestinationNameForID(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32 inID)
const
1064 CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestinationNameForIDCFString, inScope, inChannel);
1065 CFStringRef theAnswer = NULL;
1066 AudioValueTranslation theTranslation = { &inID,
sizeof(UInt32), &theAnswer,
sizeof(CFStringRef) };
1067 UInt32 theSize =
sizeof(AudioValueTranslation);
1068 GetPropertyData(theAddress, 0, NULL, theSize, &theTranslation);
1072 bool CAHALAudioDevice::HasClockSourceControl()
const
1074 CAPropertyAddress theAddress(kAudioDevicePropertyClockSource);
1075 return HasProperty(theAddress);
1078 bool CAHALAudioDevice::ClockSourceControlIsSettable()
const
1080 CAPropertyAddress theAddress(kAudioDevicePropertyClockSource);
1081 return IsPropertySettable(theAddress);
1084 UInt32 CAHALAudioDevice::GetCurrentClockSourceID()
const
1086 CAPropertyAddress theAddress(kAudioDevicePropertyClockSource);
1087 UInt32 theAnswer = 0;
1088 UInt32 theSize =
sizeof(UInt32);
1089 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
1093 void CAHALAudioDevice::SetCurrentClockSourceByID(UInt32 inID)
1095 CAPropertyAddress theAddress(kAudioDevicePropertyClockSource);
1096 UInt32 theSize =
sizeof(UInt32);
1097 SetPropertyData(theAddress, 0, NULL, theSize, &inID);
1100 UInt32 CAHALAudioDevice::GetNumberAvailableClockSources()
const
1102 CAPropertyAddress theAddress(kAudioDevicePropertyClockSources);
1103 UInt32 theAnswer = 0;
1104 if(HasProperty(theAddress))
1106 UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
1107 theAnswer = theSize /
sizeof(UInt32);
1112 void CAHALAudioDevice::GetAvailableClockSources(UInt32& ioNumberSources, UInt32* outSources)
const
1114 CAPropertyAddress theAddress(kAudioDevicePropertyClockSources);
1115 UInt32 theNumberSources = std::min(GetNumberAvailableClockSources(), ioNumberSources);
1116 UInt32 theSize = theNumberSources *
sizeof(UInt32);
1117 GetPropertyData(theAddress, 0, NULL, theSize, outSources);
1118 ioNumberSources = theSize /
sizeof(UInt32);
1121 UInt32 CAHALAudioDevice::GetAvailableClockSourceByIndex(UInt32 inIndex)
const
1123 AudioStreamID theAnswer = 0;
1124 UInt32 theNumberSources = GetNumberAvailableClockSources();
1125 if((theNumberSources > 0) && (inIndex < theNumberSources))
1127 CAAutoArrayDelete<UInt32> theSourceList(theNumberSources);
1128 GetAvailableClockSources(theNumberSources, theSourceList);
1129 theAnswer = theSourceList[inIndex];
1134 CFStringRef CAHALAudioDevice::CopyClockSourceNameForID(UInt32 inID)
const
1136 CAPropertyAddress theAddress(kAudioDevicePropertyClockSourceNameForIDCFString);
1137 CFStringRef theAnswer = NULL;
1138 AudioValueTranslation theTranslation = { &inID,
sizeof(UInt32), &theAnswer,
sizeof(CFStringRef) };
1139 UInt32 theSize =
sizeof(AudioValueTranslation);
1140 GetPropertyData(theAddress, 0, NULL, theSize, &theTranslation);
1144 UInt32 CAHALAudioDevice::GetClockSourceKindForID(UInt32 inID)
const
1146 CAPropertyAddress theAddress(kAudioDevicePropertyClockSourceKindForID);
1147 UInt32 theAnswer = inID;
1148 UInt32 theSize =
sizeof(UInt32);
1149 GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);