void SelectorControl::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const
	{
		switch (address.mSelector)
		{
			case kCMIOSelectorControlPropertyCurrentItem:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::SelectorControl::GetPropertyData: wrong data size for kCMIOSelectorControlPropertyCurrentItem");
				*static_cast<UInt32*>(data) = GetCurrentItemID();
				dataUsed = sizeof(UInt32);
				break;
			
			case kCMIOSelectorControlPropertyAvailableItems:
				{
					UInt32 numberItemsToGet = std::min((UInt32)(dataSize / sizeof(UInt32)), GetNumberItems());
					UInt32* itemIDs = static_cast<UInt32*>(data);
					for(UInt32 index = 0; index < numberItemsToGet; ++index)
					{
						itemIDs[index] = GetItemIDForIndex(index);
					}
					dataUsed = numberItemsToGet * sizeof(UInt32);
				}
				break;
			
			case kCMIOSelectorControlPropertyItemName:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::SelectorControl::GetPropertyData: wrong data size for kCMIOSelectorControlPropertyItemName");
				ThrowIf(qualifierDataSize != sizeof(UInt32), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::SelectorControl::GetPropertyData: wrong qualifier size for kCMIOSelectorControlPropertyItemName");
				*static_cast<CFStringRef*>(data) = CopyItemNameByID(*static_cast<const UInt32*>(qualifierData));
				dataUsed = sizeof(CFStringRef);
				break;
			
			default:
				Control::GetPropertyData(address, qualifierDataSize, qualifierData, dataSize, dataUsed, data);
				break;
		};
	}
void	HP_PreferredChannels::GetPropertyData(const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32& ioDataSize, void* outData) const
{
	bool isInput = inAddress.mScope == kAudioDevicePropertyScopeInput;
	switch(inAddress.mSelector)
	{
		case kAudioDevicePropertyPreferredChannelsForStereo:
			{
				ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::GetPropertyData: wrong data size for kAudioDevicePropertyPreferredChannelsForStereo");
				UInt32* theStereoChannels = static_cast<UInt32*>(outData);
				
				//	initialize the output
				theStereoChannels[0] = 1;
				theStereoChannels[1] = 2;
				
				//	get the preference
				CACFArray thePrefStereoChannels(isInput ? mPreferredInputStereoChannels : mPreferredOutputStereoChannels, false);
				if(thePrefStereoChannels.IsValid())
				{
					//	get the values from the array
					thePrefStereoChannels.GetUInt32(0, theStereoChannels[0]);
					thePrefStereoChannels.GetUInt32(1, theStereoChannels[1]);
				}
				
				if (!isInput) 
				{
					// update the cached value if necessary
					memcpy(const_cast<HP_PreferredChannels*>(this)->mOutputStereoPair, theStereoChannels, sizeof(UInt32)*2);
				}
			}
			break;
			
		case kAudioDevicePropertyPreferredChannelLayout:
			{
				ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::GetPropertyData: wrong data size for kAudioDevicePropertyPreferredChannelLayout");
				AudioChannelLayout* theChannelLayout = static_cast<AudioChannelLayout*>(outData);
				
				//	fetch the default layout from the device
				mDevice->GetDefaultChannelLayout(isInput, *theChannelLayout);
				
				//	get the pref
				CACFDictionary thePrefChannelLayout(isInput ? mPreferredInputChannelLayout : mPreferredOutputChannelLayout, false);
				if(thePrefChannelLayout.IsValid())
				{
					HP_PreferredChannels_ConstructLayoutFromDictionary(thePrefChannelLayout, *theChannelLayout);
				}
			}
			break;
			
		case 'srdd':
			{
				ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::GetPropertyData: wrong data size for 'srdd'");
				AudioChannelLayout* theChannelLayout = static_cast<AudioChannelLayout*>(outData);
				
				//	fetch the default layout from the device
				mDevice->GetDefaultChannelLayout(isInput, *theChannelLayout);
			}
			break;
	};
}
Esempio n. 3
0
void	HP_Stream::GetPropertyData(const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32& ioDataSize, void* outData) const
{
	//	take and hold the state mutex
	CAMutex::Locker theStateMutex(const_cast<HP_Device*>(mOwningDevice)->GetStateMutex());
	
	switch(inAddress.mSelector)
	{
		case kAudioObjectPropertyName:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyName");
			*static_cast<CFStringRef*>(outData) = CopyStreamName();
			break;
			
		case kAudioObjectPropertyManufacturer:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyName");
			*static_cast<CFStringRef*>(outData) = CopyStreamManufacturerName();
			break;
			
		case kAudioObjectPropertyElementName:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyElementName");
			*static_cast<CFStringRef*>(outData) = CopyElementFullName(inAddress);
			break;
			
		case kAudioObjectPropertyElementCategoryName:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyElementCategoryName");
			*static_cast<CFStringRef*>(outData) = CopyElementCategoryName(inAddress);
			break;
			
		case kAudioObjectPropertyElementNumberName:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioObjectPropertyElementNumberName");
			*static_cast<CFStringRef*>(outData) = CopyElementNumberName(inAddress);
			break;
			
		case kAudioStreamPropertyDirection:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyDirection");
			*static_cast<UInt32*>(outData) = IsInput() ? 1 : 0;
			break;
			
		case kAudioStreamPropertyTerminalType:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyTerminalType");
			*static_cast<UInt32*>(outData) = GetTerminalType();
			break;
			
		case kAudioStreamPropertyStartingChannel:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyStartingChannel");
			*static_cast<UInt32*>(outData) = GetStartingDeviceChannelNumber();
			break;
			
		case kAudioStreamPropertyLatency:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_Stream::GetPropertyData: wrong data size for kAudioStreamPropertyLatency");
			*static_cast<UInt32*>(outData) = GetLatency();
			break;
			
		default:
			HP_Object::GetPropertyData(inAddress, inQualifierDataSize, inQualifierData, ioDataSize, outData);
			break;
	};
}
Esempio n. 4
0
UInt32	CAHALAudioDevice::GetNumberStreams(bool inIsInput) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyStreams, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
	UInt32 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
	theAnswer /= SizeOf32(AudioObjectID);
	return theAnswer;
}
Esempio n. 5
0
UInt32	CAHALAudioSystemObject::GetNumberAudioDevices() const
{
	CAPropertyAddress theAddress(kAudioHardwarePropertyDevices);
	UInt32 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
	theAnswer /= SizeOf32(AudioObjectID);
	return theAnswer;
}
Esempio n. 6
0
OSStatus
PA_Stream::GetPropertyInfo(UInt32 inChannel,
			   AudioDevicePropertyID inPropertyID,
			   UInt32 *outSize,
			   Boolean *outWritable)
{
	AudioObjectPropertyAddress addr;
	OSStatus ret = kAudioHardwareNoError;
	
	addr.mSelector = inPropertyID;
	addr.mElement = inChannel;
	addr.mScope = 0;
	
	if (!HasProperty(&addr))
		return kAudioHardwareUnknownPropertyError;
	
	if (outWritable)
		ret = IsPropertySettable(&addr, outWritable);
	
	if (ret != kAudioHardwareNoError)
		return ret;
	
	if (outSize)
		ret = GetPropertyDataSize(&addr, 0, NULL, outSize);
	
	return ret;
}
UInt32	CAHALAudioObject::GetNumberOwnedObjects(AudioClassID inClass) const
{
	//	set up the return value
	UInt32 theAnswer = 0;
	
	//	set up the property address
	CAPropertyAddress theAddress(kAudioObjectPropertyOwnedObjects);
	
	//	figure out the qualifier
	UInt32 theQualifierSize = 0;
	void* theQualifierData = NULL;
	if(inClass != 0)
	{
		theQualifierSize = sizeof(AudioObjectID);
		theQualifierData = &inClass;
	}
	
	//	get the property data size
	theAnswer = GetPropertyDataSize(theAddress, theQualifierSize, theQualifierData);
	
	//	calculate the number of object IDs
	theAnswer /= sizeof(AudioObjectID);
	
	return theAnswer;
}
Esempio n. 8
0
UInt32	CAHALAudioStream::GetNumberAvailablePhysicalFormats() const
{
	CAPropertyAddress theAddress(kAudioStreamPropertyAvailablePhysicalFormats);
	UInt32 theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
	theAnswer /= SizeOf32(AudioStreamRangedDescription);
	return theAnswer;
}
UInt32	CAAudioHardwareStream::GetNumberAvailableDataSources() const
{
	UInt32 theAnswer = 0;
	if(HasDataSourceControl())
	{
		UInt32 theSize = GetPropertyDataSize(0, kAudioDevicePropertyDataSources);
		theAnswer = theSize / sizeof(UInt32);
	}
	return theAnswer;
}
Esempio n. 10
0
UInt32	CAHALAudioDevice::GetNumberAvailableClockSources() const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyClockSources);
	UInt32 theAnswer = 0;
	if(HasProperty(theAddress))
	{
		UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
		theAnswer = theSize / SizeOf32(UInt32);
	}
	return theAnswer;
}
Esempio n. 11
0
UInt32	CAHALAudioDevice::GetNumberRelatedAudioDevices() const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyRelatedDevices);
	UInt32 theAnswer = 0;
	if(HasProperty(theAddress))
	{
		theAnswer = GetPropertyDataSize(theAddress, 0, NULL);
		theAnswer /= SizeOf32(AudioObjectID);
	}
	return theAnswer;
}
Esempio n. 12
0
UInt32	CAHALAudioDevice::GetNumberAvailableDataSources(AudioObjectPropertyScope inScope, UInt32 inChannel) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyDataSources, inScope, inChannel);
	UInt32 theAnswer = 0;
	if(HasProperty(theAddress))
	{
		UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
		theAnswer = theSize / SizeOf32(UInt32);
	}
	return theAnswer;
}
Esempio n. 13
0
UInt32	CAHALAudioDevice::GetNumberAvailableNominalSampleRateRanges() const
{
	UInt32 theAnswer = 0;
	CAPropertyAddress theAddress(kAudioDevicePropertyAvailableNominalSampleRates);
	if(HasProperty(theAddress))
	{
		UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
		theAnswer = theSize / SizeOf32(AudioValueRange);
	}
	return theAnswer;
}
	UInt32 Device::GetNumberVideoDigitizerComponents() const
	{
		UInt32 answer = 0;
		PropertyAddress address(kCMIODevicePropertyVideoDigitizerComponents);

		if (HasProperty(address))
		{
			answer = GetPropertyDataSize(address, 0, NULL);
			answer = answer / sizeof(ComponentDescription);
		}
		return answer;
	}
	void Control::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const
	{
		switch (address.mSelector)
		{
			case kCMIOObjectPropertyName:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOObjectPropertyName");
				*static_cast<CFStringRef*>(data) = CopyName();
				dataUsed = sizeof(CFStringRef);
				break;
				
			case kCMIOObjectPropertyManufacturer:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOObjectPropertyManufacturer");
				*static_cast<CFStringRef*>(data) = CopyManufacturerName();
				dataUsed = sizeof(CFStringRef);
				break;
				
			case kCMIOControlPropertyScope:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOControlPropertyScope");
				*static_cast<CMIOObjectPropertyScope*>(data) = GetPropertyScope();
				dataUsed = sizeof(CMIOObjectPropertyScope);
				break;
				
			case kCMIOControlPropertyElement:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOControlPropertyElement");
				*static_cast<CMIOObjectPropertyElement*>(data) = GetPropertyElement();
				dataUsed = sizeof(CMIOObjectPropertyElement);
				break;
				
			case kCMIOControlPropertyVariant:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Control::GetPropertyData: wrong data size for kCMIOControlPropertyVariant");
				*static_cast<UInt32*>(data) = GetVariant();
				dataUsed = sizeof(UInt32);
				break;
				
			default:
				Object::GetPropertyData(address, qualifierDataSize, qualifierData, dataSize, dataUsed, data);
				break;
		};
	}
Esempio n. 16
0
UInt32	CAHALAudioDevice::GetTotalNumberChannels(bool inIsInput) const
{
	UInt32 theAnswer = 0;
	CAPropertyAddress theAddress(kAudioDevicePropertyStreamConfiguration, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
	UInt32 theSize = GetPropertyDataSize(theAddress, 0, NULL);
	CAAutoFree<AudioBufferList> theBufferList(theSize);
	GetPropertyData(theAddress, 0, NULL, theSize, theBufferList);
	for(UInt32 theIndex = 0; theIndex < theBufferList->mNumberBuffers; ++theIndex)
	{
		theAnswer += theBufferList->mBuffers[theIndex].mNumberChannels;
	}
	return theAnswer;
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// GetNumberAllPossibleFrameRates()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	UInt32 Stream::GetNumberAllPossibleFrameRates() const
	{
		// The idiom of passing a NULL format description is only supported by streams that support
		// preferred frame rates.
		UInt32 result = 0;
		if (HasPreferredFrameRate())
		{
			CMFormatDescriptionRef nullFormat = NULL;  // Triggers returning all possible frame rates
			UInt32 size = GetPropertyDataSize(PropertyAddress(kCMIOStreamPropertyFrameRates), sizeof(nullFormat), &nullFormat);
			result = size / sizeof(Float64);
		}
		return result;
	}
	UInt32 SelectorControl::GetNumberItems() const
	{
		//	figure out the qualifier
		CMIOObjectID IDvalue;
		UInt32 theQualifierSize = 0;
		void* theQualifierData = NULL;
		theQualifierSize = sizeof(CMIOObjectID);
		theQualifierData = &IDvalue;
		
		//	figure out how much space to allocate
		UInt32 theDataSize = GetPropertyDataSize(PropertyAddress(kCMIOSelectorControlPropertyAvailableItems), theQualifierSize, theQualifierData);
		UInt32 theNumberObjectIDs = theDataSize / sizeof(CMIOObjectID);
		return (theNumberObjectIDs);
	}
	void SelectorControl::SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data)
	{
		switch (address.mSelector)
		{
			case kCMIOSelectorControlPropertyCurrentItem:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::SelectorControl::GetPropertyData: wrong data size for kCMIOSelectorControlPropertyCurrentItem");
				SetCurrentItemByID(*static_cast<const UInt32*>(data));
				break;
		
			default:
				Control::SetPropertyData(address, qualifierDataSize, qualifierData, dataSize, data);
				break;
		};
	}
	void BooleanControl::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const
	{
		switch (address.mSelector)
		{
			case kCMIOBooleanControlPropertyValue:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::BooleanControl::GetPropertyData: wrong data size for kCMIOBooleanControlPropertyValue");
				*static_cast<UInt32*>(data) = GetValue() ? 1 : 0;
				dataUsed = sizeof(UInt32);
				break;
			
			default:
				Control::GetPropertyData(address, qualifierDataSize, qualifierData, dataSize, dataUsed, data);
				break;
		};
	}
Esempio n. 21
0
void	SHP_PlugIn::GetPropertyData(const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32& ioDataSize, void* outData) const
{
	switch(inAddress.mSelector)
	{
		case kAudioObjectPropertyName:
			ThrowIf(ioDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "SHP_PlugIn::GetPropertyData: wrong data size for kAudioObjectPropertyName");
			*static_cast<CFStringRef*>(outData) = CFSTR("com.apple.audio.SampleHardwarePlugIn");
			CFRetain(*static_cast<CFStringRef*>(outData));
			break;
			
		default:
			HP_HardwarePlugIn::GetPropertyData(inAddress, inQualifierDataSize, inQualifierData, ioDataSize, outData);
			break;
	};
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// GetPropertyData()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	void PlugIn::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const
	{
		switch (address.mSelector)
		{
			case kCMIOObjectPropertyName:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::Sample::PlugIn::GetPropertyData: wrong data size for kCMIOObjectPropertyName");
				*static_cast<CFStringRef*>(data) = CFSTR("com.apple.cmio.DAL.Sample");
				CFRetain(*static_cast<CFStringRef*>(data));
				dataUsed = sizeof(CFStringRef);
				break;
				
			default:
				DP::PlugIn::GetPropertyData(address, qualifierDataSize, qualifierData, dataSize, dataUsed, data);
				break;
		};
	}
	UInt32 Device::GetTotalNumberChannels(CMIOObjectPropertyScope scope) const
	{
		UInt32 answer = 0;
		#warning Device::GetTotalNumberChannels() needs to be implemented
		PropertyAddress address(kCMIODevicePropertyStreamConfiguration, scope);
		UInt32 size = GetPropertyDataSize(address, 0, NULL);
		CAAutoFree<CMIODeviceStreamConfiguration> streamConfiguration(size);
		UInt32 dataUsed = 0;
		GetPropertyData(address, 0, NULL, size, dataUsed, streamConfiguration);

		for(UInt32 index = 0; index < streamConfiguration->mNumberStreams; ++index)
		{
			answer += streamConfiguration->mNumberChannels[index];
		}
		return answer;
	}
AudioObjectID	CAHALAudioObject::GetOwnedObjectByIndex(AudioClassID inClass, UInt32 inIndex)
{
	//	set up the property address
	CAPropertyAddress theAddress(kAudioObjectPropertyOwnedObjects);
	
	//	figure out the qualifier
	UInt32 theQualifierSize = 0;
	void* theQualifierData = NULL;
	if(inClass != 0)
	{
		theQualifierSize = sizeof(AudioObjectID);
		theQualifierData = &inClass;
	}
	
	//	figure out how much space to allocate
	UInt32 theDataSize = GetPropertyDataSize(theAddress, theQualifierSize, theQualifierData);
	UInt32 theNumberObjectIDs = theDataSize / sizeof(AudioObjectID);
	
	//	set up the return value
	AudioObjectID theAnswer = 0;
	
	//	maker sure the index is in range
	if(inIndex < theNumberObjectIDs)
	{
		//	allocate it
		CAAutoArrayDelete<AudioObjectID> theObjectList(theDataSize / sizeof(AudioObjectID));
		
		//	get the property data
		GetPropertyData(theAddress, theQualifierSize, theQualifierData, theDataSize, theObjectList);
		
		//	get the return value
		theAnswer = theObjectList[inIndex];
	}
	
	return theAnswer;
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// FeatureControl::SetPropertyData()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	void FeatureControl::SetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, const void* data)
	{
		switch (address.mSelector)
		{
			case kCMIOFeatureControlPropertyOnOff:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyOnOff");
				SetOnOff(*static_cast<const UInt32*>(data));
				break;
		
			case kCMIOFeatureControlPropertyAutomaticManual:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyAutomaticManual");
				SetAutomaticManual(*static_cast<const UInt32*>(data));
				break;
		
			case kCMIOFeatureControlPropertyAbsoluteNative:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyAutomaticManual");
				SetAbsoluteNative(*static_cast<const UInt32*>(data));
				break;
		
			case kCMIOFeatureControlPropertyTune:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyTune");
				SetTune(*static_cast<const UInt32*>(data));
				break;

			case kCMIOFeatureControlPropertyNativeValue:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyNativeValue");
				SetNativeValue(*static_cast<const Float32*>(data));
				break;
		
			case kCMIOFeatureControlPropertyAbsoluteValue:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyAbsoluteValue");
				SetAbsoluteValue(*static_cast<const Float32*>(data));
				break;
		
			default:
				Control::SetPropertyData(address, qualifierDataSize, qualifierData, dataSize, data);
				break;
		};
	}
Esempio n. 26
0
void	HP_PreferredChannels::SetPropertyData(const AudioObjectPropertyAddress& inAddress, UInt32 inQualifierDataSize, const void* inQualifierData, UInt32 inDataSize, const void* inData, const AudioTimeStamp* /*inWhen*/)
{
	CFStringRef thePrefsKey = NULL;
	bool isInput = inAddress.mScope == kAudioDevicePropertyScopeInput;
	UInt32 theTotalNumberChannels = mDevice->GetTotalNumberChannels(isInput);
	switch(inAddress.mSelector)
	{
		case kAudioDevicePropertyPreferredChannelsForStereo:
			{
				ThrowIf(inDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::SetPropertyData: wrong data size for kAudioDevicePropertyPreferredChannelsForStereo");
				const UInt32* theStereoChannels = static_cast<const UInt32*>(inData);
				
				//	create an array to hold the prefs value
				CACFArray thePrefStereoChannels(true);
				
				//	put in the left channel
				thePrefStereoChannels.AppendUInt32(std::min(std::max(theStereoChannels[0], (UInt32)1), theTotalNumberChannels));
				
				//	put in the right channel
				thePrefStereoChannels.AppendUInt32(std::min(std::max(theStereoChannels[1], (UInt32)1), theTotalNumberChannels));
				
				//	set the value in the prefs
				thePrefsKey = (isInput ? mInputStereoPrefsKey : mOutputStereoPrefsKey);
				CACFPreferences::SetValue(thePrefsKey, thePrefStereoChannels.GetCFArray(), false, true, true);
				
				CFArrayRef theStereoChannelsArray = isInput ? mPreferredInputStereoChannels : mPreferredOutputStereoChannels;

				//	if the value changed re-cache it and send notifications
				CFArrayRef array = CACFPreferences::CopyArrayValue(thePrefsKey, false, true);
				//	release the old array
				if (theStereoChannelsArray != NULL)
					CFRelease(theStereoChannelsArray);

				//	save the new one
				if (isInput)
					mPreferredInputStereoChannels = array;
				else
					mPreferredOutputStereoChannels = array;

				//	send property changed
				mDevice->PropertiesChanged(1, &inAddress);

				//	send the notification
				SendChangeNotification(thePrefsKey);
			}
			break;
			
		case kAudioDevicePropertyPreferredChannelLayout:
			{
				ThrowIf(inDataSize != GetPropertyDataSize(inAddress, inQualifierDataSize, inQualifierData), CAException(kAudioHardwareBadPropertySizeError), "HP_PreferredChannels::SetPropertyData: wrong data size for kAudioDevicePropertyPreferredChannelLayout");
				const AudioChannelLayout* theChannelLayout = static_cast<const AudioChannelLayout*>(inData);
				
				//	create a dictionary to hold the prefs value
				CACFDictionary thePrefChannelLayout(true);
				
				//	fill out the dictionary
				HP_PreferredChannels_ConstructDictionaryFromLayout(*theChannelLayout, thePrefChannelLayout);
				
				//	set the value in the prefs
				thePrefsKey = (isInput ? mInputChannelLayoutPrefsKey : mOutputChannelLayoutPrefsKey);
				CACFPreferences::SetValue(thePrefsKey, thePrefChannelLayout.GetDict(), false, true, true);
				
				CFDictionaryRef theChannelLayoutDict = isInput ? mPreferredInputChannelLayout : mPreferredOutputChannelLayout;

				//	if the value changed re-cache it and send notifications
				CFDictionaryRef dictionary = CACFPreferences::CopyDictionaryValue(thePrefsKey, false, true);

				//	release the old dict
				if (theChannelLayoutDict != NULL)
					CFRelease(theChannelLayoutDict);

				//	save the new one
				if (isInput)
					mPreferredInputChannelLayout = dictionary;
				else
					mPreferredOutputChannelLayout = dictionary;

				//	send property changed
				mDevice->PropertiesChanged(1, &inAddress);

				//	send the notification
				SendChangeNotification(thePrefsKey);
			}
			break;
	};
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// GetNumberFrameRates()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	UInt32 Stream::GetNumberFrameRates() const
	{
		UInt32 size = GetPropertyDataSize(PropertyAddress(kCMIOStreamPropertyFrameRates), 0, NULL);
		return size / sizeof(Float64);
	}
Esempio n. 28
0
UInt32	CAAudioHardwareSystem::GetNumberDevices()
{
	UInt32 theAnswer = GetPropertyDataSize(kAudioHardwarePropertyDevices);
	theAnswer /= sizeof(AudioDeviceID);
	return theAnswer;
}
UInt32	CAAudioHardwareStream::GetNumberAvailablePhysicalFormats() const
{
	UInt32 theAnswer = GetPropertyDataSize(0, kAudioStreamPropertyPhysicalFormats);
	theAnswer /= sizeof(AudioStreamBasicDescription);
	return theAnswer;
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// FeatureControl::GetPropertyDataSize()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	void FeatureControl::GetPropertyData(const CMIOObjectPropertyAddress& address, UInt32 qualifierDataSize, const void* qualifierData, UInt32 dataSize, UInt32& dataUsed, void* data) const
	{
		switch (address.mSelector)
		{
			case kCMIOFeatureControlPropertyOnOff:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyOnOff");
				*static_cast<UInt32*>(data) = GetOnOff();
				dataUsed = sizeof(UInt32);
				break;
			
			case kCMIOFeatureControlPropertyAutomaticManual:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyAutomaticManual");
				*static_cast<UInt32*>(data) = GetAutomaticManual();
				dataUsed = sizeof(UInt32);
				break;
			
			case kCMIOFeatureControlPropertyAbsoluteNative:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyAbsoluteNative");
				*static_cast<UInt32*>(data) = GetAbsoluteNative();
				dataUsed = sizeof(UInt32);
				break;
			
			case kCMIOFeatureControlPropertyTune:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyTune");
				*static_cast<UInt32*>(data) = GetTune();
				dataUsed = sizeof(UInt32);
				break;

			case kCMIOFeatureControlPropertyNativeValue:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyNativeValue");
				*static_cast<Float32*>(data) = GetNativeValue();
				dataUsed = sizeof(Float32);
				break;
			
			case kCMIOFeatureControlPropertyAbsoluteValue:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyAbsoluteValue");
				*static_cast<Float32*>(data) = GetAbsoluteValue();
				dataUsed = sizeof(Float32);
				break;
			
			case kCMIOFeatureControlPropertyNativeRange:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyNativeRange");
				static_cast<AudioValueRange*>(data)->mMinimum = GetMinimumNativeValue();
				static_cast<AudioValueRange*>(data)->mMaximum = GetMaximumNativeValue();
				dataUsed = dataSize;
				break;
			
			case kCMIOFeatureControlPropertyAbsoluteRange:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyAbsoluteRange");
				static_cast<AudioValueRange*>(data)->mMinimum = GetMinimumAbsoluteValue();
				static_cast<AudioValueRange*>(data)->mMaximum = GetMaximumAbsoluteValue();
				dataUsed = dataSize;
				break;
			
			case kCMIOFeatureControlPropertyConvertNativeToAbsolute:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyConvertNativeToAbsolute");
				*static_cast<Float32*>(data) = ConverNativeValueToAbsoluteValue(*static_cast<Float32*>(data));
				dataUsed = sizeof(Float32);
				break;
			
			case kCMIOFeatureControlPropertyConvertAbsoluteToNative:
				ThrowIf(dataSize != GetPropertyDataSize(address, qualifierDataSize, qualifierData), CAException(kCMIOHardwareBadPropertySizeError), "CMIO::DP::FeatureControl::GetPropertyData: wrong data size for kCMIOFeatureControlPropertyConvertAbsoluteToNative");
				*static_cast<Float32*>(data) = ConverAbsoluteValueToNativeValue(*static_cast<Float32*>(data));
				dataUsed = sizeof(Float32);
				break;
		
			default:
				Control::GetPropertyData(address, qualifierDataSize, qualifierData, dataSize, dataUsed, data);
				break;
		};
	}