Float64 CAAudioHardwareDevice::GetNominalSampleRate() const
{
Float64 theAnswer = 0;
UInt32 theSize = sizeof(Float64);
GetPropertyData(0,
kAudioDeviceSectionGlobal,
kAudioDevicePropertyNominalSampleRate,
theSize,
&theAnswer);
return theAnswer;
}
void CAAudioHardwareDevice::SetNominalSampleRate(Float64 inSampleRate)
{
UInt32 theSize = sizeof(Float64);
SetPropertyData(0,
kAudioDeviceSectionGlobal,
kAudioDevicePropertyNominalSampleRate,
theSize,
&inSampleRate);
}
UInt32 CAAudioHardwareDevice::GetNumberNominalSampleRateRanges() const
{
UInt32 theSize = GetPropertyDataSize(0,
kAudioDeviceSectionGlobal,
kAudioDevicePropertyAvailableNominalSampleRates);
return (theSize / sizeof(AudioValueRange) );
}
void GetNominalSampleRateRanges(UInt32& ioNumberRanges,
AudioValueRange* outRanges) const
{
UInt32 theSize = ioNumberRanges * sizeof(AudioValueRange);
GetPropertyData(0,
kAudioDeviceSectionGlobal,
kAudioDevicePropertyAvailableNominalSampleRates,
theSize,
outRanges);
ioNumberRanges = theSize / sizeof(AudioValueRange);
}
UInt32 CAAudioHardwareDevice::GetPropertyDataSize(UInt32 inChannel,
CAAudioHardwareDeviceSectionID inSection,
AudioHardwarePropertyID inPropertyID) const
{
UInt32 theSize = 0;
OSStatus theError;
theError = AudioDeviceGetPropertyInfo(mAudioDeviceID,
inChannel,
inSection,
inPropertyID,
&theSize,
NULL);
ThrowIfError(theError,
CAException(theError),
"error getting info about a property");
return theSize;
}
void CAAudioHardwareDevice::GetPropertyData(UInt32 inChannel,
CAAudioHardwareDeviceSectionID inSection,
AudioHardwarePropertyID inPropertyID,
UInt32& ioDataSize,
void* outData) const
{
OSStatus theError;
theError = AudioDeviceGetProperty(mAudioDeviceID,
inChannel,
inSection,
inPropertyID,
&ioDataSize,
outData);
ThrowIfError(theError,
CAException(theError),
"error getting the value of a property");
}
void CAAudioHardwareDevice::SetPropertyData(UInt32 inChannel,
CAAudioHardwareDeviceSectionID inSection,
AudioHardwarePropertyID inPropertyID,
UInt32 inDataSize,
const void* inData,
const AudioTimeStamp* inWhen)
{
OSStatus theError;
theError = AudioDeviceSetProperty(mAudioDeviceID,
inWhen,
inChannel,
inSection,
inPropertyID,
inDataSize,
inData);
ThrowIfError(theError,
CAException(theError),
"error setting the value of a property");
}
|