Esempio n. 1
0
void	CAHALAudioDevice::GetStereoPanControlChannels(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32& outLeftChannel, UInt32& outRightChannel) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyStereoPanChannels, inScope, inChannel);
	UInt32 theValue[2] = { 0, 0 };
	UInt32 theSize = 2 * sizeof(UInt32);
	GetPropertyData(theAddress, 0, NULL, theSize, theValue);
	outLeftChannel = theValue[0];
	outRightChannel = theValue[1];
}
Esempio n. 2
0
CFStringRef	CAHALAudioDevice::CopyDataDestinationNameForID(AudioObjectPropertyScope inScope, UInt32 inChannel, UInt32 inID) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyPlayThruDestinationNameForIDCFString, inScope, inChannel);
	CFStringRef theAnswer = NULL;
	AudioValueTranslation theTranslation = { &inID, sizeof(UInt32), &theAnswer, sizeof(CFStringRef) };
	UInt32 theSize = sizeof(AudioValueTranslation);
	GetPropertyData(theAddress, 0, NULL, theSize, &theTranslation);
	return theAnswer;
}
Esempio n. 3
0
void	CAHALAudioDevice::GetIOBufferSizeRange(UInt32& outMinimum, UInt32& outMaximum) const
{
	AudioValueRange theAnswer = { 0, 0 };
	CAPropertyAddress theAddress(kAudioDevicePropertyBufferFrameSizeRange);
	UInt32 theSize = sizeof(AudioValueRange);
	GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
	outMinimum = static_cast<UInt32>(theAnswer.mMinimum);
	outMaximum = static_cast<UInt32>(theAnswer.mMaximum);
}
Esempio n. 4
0
void	CAHALAudioDevice::GetPreferredStereoChannels(bool inIsInput, UInt32& outLeft, UInt32& outRight) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyPreferredChannelsForStereo, inIsInput ? kAudioDevicePropertyScopeInput : kAudioDevicePropertyScopeOutput);
	UInt32 theStereoPair[2] = { 0, 0 };
	UInt32 theSize = 2 * sizeof(UInt32);
	GetPropertyData(theAddress, 0, NULL, theSize, theStereoPair);
	outLeft = theStereoPair[0];
	outRight = theStereoPair[1];
}
Esempio n. 5
0
UInt32	CAHALAudioDevice::GetClockSourceKindForID(UInt32 inID) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyClockSourceKindForID);
	UInt32 theAnswer = 0;
	AudioValueTranslation theTranslation = { &inID, sizeof(UInt32), &theAnswer, sizeof(UInt32) };
	UInt32 theSize = sizeof(AudioValueTranslation);
	GetPropertyData(theAddress, 0, NULL, theSize, &theTranslation);
	return theAnswer;
}
Esempio n. 6
0
CFStringRef	CAHALAudioDevice::CopyClockSourceNameForID(UInt32 inID) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyClockSourceNameForIDCFString);
	CFStringRef theAnswer = NULL;
	AudioValueTranslation theTranslation = { &inID, sizeof(UInt32), &theAnswer, sizeof(CFStringRef) };
	UInt32 theSize = sizeof(AudioValueTranslation);
	GetPropertyData(theAddress, 0, NULL, theSize, &theTranslation);
	return theAnswer;
}
AudioObjectID	CAHALAudioSystemObject::GetAudioPlugInForBundleID(CFStringRef inUID) const
{
	AudioObjectID theAnswer = kAudioObjectUnknown;
	AudioValueTranslation theValue = { &inUID, sizeof(CFStringRef), &theAnswer, sizeof(AudioObjectID) };
	CAPropertyAddress theAddress(kAudioHardwarePropertyPlugInForBundleID);
	UInt32 theSize = sizeof(AudioValueTranslation);
	GetPropertyData(theAddress, 0, NULL, theSize, &theValue);
	return theAnswer;
}
void	CAAudioHardwareStream::GetAvailableDataSources(UInt32& ioNumberSources, UInt32* outSources) const
{
	UInt32 theNumberSources = std::min(GetNumberAvailableDataSources(), ioNumberSources);
	UInt32 theSize = theNumberSources * sizeof(UInt32);
	GetPropertyData(0, kAudioDevicePropertyDataSources, theSize, outSources);
	ioNumberSources = theSize / sizeof(UInt32);
	UInt32* theFirstItem = &(outSources[0]);
	UInt32* theLastItem = theFirstItem + ioNumberSources;
	std::sort(theFirstItem, theLastItem);
}
	void Control::Show() const
	{
		// Make a string for the class ID
		char classID[] = CA4CCToCString(mClassID);
		
		// Get the object's name
		PropertyAddress address(kCMIOObjectPropertyName, kCMIOObjectPropertyScopeGlobal, kCMIOObjectPropertyElementMaster);
		CFStringRef cfname = NULL;
		UInt32 dataUsed = 0;
		try
		{
			GetPropertyData(address, 0, NULL, sizeof(CFStringRef), dataUsed, &cfname);
		}
		catch(...)
		{
			cfname = NULL;
		}
		
		// Make a C string out of the name
		char name[256];
		name[0] = 0;
		if (cfname != NULL)
		{
			CFIndex length = 0;
			CFRange range = { 0, CFStringGetLength(cfname) };
			CFStringGetBytes(cfname, range, kCFStringEncodingUTF8, 0, false, (UInt8*)name, 255, &length);
			name[length] = 0;
			CFRelease(cfname);
		}
		
		// Get a string for the scope
		const char* scope = NULL;
		switch (GetPropertyScope())
		{
			case kCMIODevicePropertyScopeInput:
				scope = "Input";
				break;
			
			case kCMIODevicePropertyScopeOutput:
				scope = "Output";
				break;
			
			case kCMIODevicePropertyScopePlayThrough:
				scope = "Play Through";
				break;
			
			case kCMIOObjectPropertyScopeGlobal:
			default:
				scope = "Global";
				break;
		};
		
		// Print the information to the standard output
		printf("CMIOObjectID:\t\t0x%lX\n\tCMIOClassID:\t'%s'\n\tName:\t\t\t%s\n\tScope:\t\t\t%s\n\tChannel:\t\t%lu\n", (long unsigned int)mObjectID, classID, name, scope, (long unsigned int)GetPropertyElement());
	}
Esempio n. 10
0
pid_t	CAHALAudioDevice::GetHogModeOwner() const
{
	pid_t theAnswer = -1;
	CAPropertyAddress theAddress(kAudioDevicePropertyHogMode);
	if(HasProperty(theAddress))
	{
		UInt32 theSize = sizeof(pid_t);
		GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
	}
	return theAnswer;
}
	void Device::GetStreams(CMIOObjectPropertyScope scope, UInt32& ioNumberStreams, CMIOStreamID* streamList) const
	{
		ioNumberStreams = std::min(GetNumberStreams(scope), ioNumberStreams);
		UInt32 size = ioNumberStreams * sizeof(CMIOStreamID);
		UInt32 dataUsed = 0;
		GetPropertyData(PropertyAddress(kCMIODevicePropertyStreams, scope), 0, NULL, size, dataUsed, streamList);
		ioNumberStreams = size / sizeof(CMIOStreamID);
		CMIOStreamID* firstItem = &(streamList[0]);
		CMIOStreamID* lastItem = firstItem + ioNumberStreams;
		std::sort(firstItem, lastItem);
	}
	bool Device::IsAlive() const
	{
		bool answer = HasProperty(PropertyAddress(kCMIODevicePropertyDeviceIsAlive));
		if (answer)
		{
			UInt32 isAlive = 0;
			UInt32 dataUsed = 0;
			GetPropertyData(PropertyAddress(kCMIODevicePropertyDeviceIsAlive), 0, NULL, sizeof(UInt32), dataUsed, &isAlive);
			answer = isAlive != 0;
		}
		return answer;
	}
Esempio n. 13
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;
}
Esempio n. 14
0
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;
}
Esempio n. 15
0
void	CAHALAudioDevice::GetAvailableNominalSampleRateRanges(UInt32& ioNumberRanges, AudioValueRange* outRanges) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyAvailableNominalSampleRates);
	if(HasProperty(theAddress))
	{
		UInt32 theSize = ioNumberRanges * SizeOf32(AudioValueRange);
		GetPropertyData(theAddress, 0, NULL, theSize, outRanges);
		ioNumberRanges = theSize / SizeOf32(AudioValueRange);
	}
	else
	{
		ioNumberRanges = 0;
	}
}
	UInt32 SelectorControl::GetItemIDForIndex(UInt32 inItemIndex) const
	{
		UInt32 answer = 0xFFFFFFFF;	// Default to the featuring being on
		UInt32 numberOfItems = GetNumberItems();
		if (numberOfItems > 0)
		{
			ThrowIf(inItemIndex >= numberOfItems, CAException(kCMIOHardwareIllegalOperationError), "SelectorControl::GetItemIDForIndex: index out of range");			
			CAAutoArrayDelete<UInt32> itemList(numberOfItems);
			UInt32 size = numberOfItems * sizeof(CMIODeviceID);
			UInt32 dataUsed = 0;
			GetPropertyData(PropertyAddress(kCMIOSelectorControlPropertyAvailableItems),0, NULL, size, dataUsed, itemList);
			answer = itemList[inItemIndex];
		}
		return answer;
	}
Esempio n. 17
0
Float64	CAHALAudioDevice::GetActualSampleRate() const
{
	Float64 theAnswer = 0;
	CAPropertyAddress theAddress(kAudioDevicePropertyActualSampleRate);
	if(HasProperty(theAddress))
	{
		UInt32 theSize = sizeof(Float64);
		GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
	}
	else
	{
		theAnswer = GetNominalSampleRate();
	}
	return theAnswer;
}
	CFStringRef SelectorControl::CopyItemNameByIndex(UInt32 inItemIndex) const
	{
		CFStringRef answer = NULL;
		UInt32 numberOfItems = GetNumberItems();
		if (numberOfItems > 0)
		{
			ThrowIf(inItemIndex >= numberOfItems, CAException(kCMIOHardwareIllegalOperationError), "SelectorControl::CopyItemNameByIndex: index out of range");			
			CAAutoArrayDelete<UInt32> itemList(numberOfItems);
			UInt32 size = numberOfItems * sizeof(CMIODeviceID);
			UInt32 dataUsed = 0;
			GetPropertyData(PropertyAddress(kCMIOSelectorControlPropertyAvailableItems),0, NULL, size, dataUsed, itemList);
			answer = CopyItemNameByID(itemList[inItemIndex]);
		}
		return answer;
	}
	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;
	}
Esempio n. 20
0
void	CAHALAudioDevice::GetRelatedAudioDevices(UInt32& ioNumberRelatedDevices, AudioObjectID* outRelatedDevices) const
{
	CAPropertyAddress theAddress(kAudioDevicePropertyRelatedDevices);
	if(HasProperty(theAddress))
	{
		UInt32 theSize = ioNumberRelatedDevices * SizeOf32(AudioObjectID);
		GetPropertyData(theAddress, 0, NULL, theSize, outRelatedDevices);
		ioNumberRelatedDevices = theSize / SizeOf32(AudioObjectID);
	}
	else
	{
		UInt32 theSize = ioNumberRelatedDevices * SizeOf32(AudioObjectID);
		memset(outRelatedDevices, 0, theSize);
		ioNumberRelatedDevices = 0;
	}
}
AudioClassID	CAHALAudioObject::GetClassID() const
{
	//	set up the return value
	AudioClassID theAnswer = 0;
	
	//	set up the property address
	CAPropertyAddress theAddress(kAudioObjectPropertyClass);
	
	//	make sure the property exists
	if(HasProperty(theAddress))
	{
		UInt32 theSize = sizeof(AudioClassID);
		GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
	}
	
	return theAnswer;
}
Esempio n. 22
0
OSStatus
PA_Stream::GetProperty(UInt32 inChannel,
		       AudioDevicePropertyID inPropertyID,
		       UInt32 *ioPropertyDataSize,
		       void *outPropertyData)
{
	AudioObjectPropertyAddress addr;
	
	addr.mSelector = inPropertyID;
	addr.mElement = inChannel;
	addr.mScope = 0;
	
	if (!HasProperty(&addr))
		return kAudioHardwareUnknownPropertyError;
	
	return GetPropertyData(&addr, 0, NULL, ioPropertyDataSize, outPropertyData);
}
CFStringRef	CAHALAudioObject::CopyNumberNameForElement(AudioObjectPropertyScope inScope, AudioObjectPropertyElement inElement) const
{
	//	set up the return value
	CFStringRef theAnswer = NULL;
	
	//	set up the property address
	CAPropertyAddress theAddress(kAudioObjectPropertyElementNumberName, inScope, inElement);
	
	//	make sure the property exists
	if(HasProperty(theAddress))
	{
		//	get the property data
		UInt32 theSize = sizeof(CFStringRef);
		GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
	}
	
	return theAnswer;
}
CFStringRef	CAHALAudioObject::CopyManufacturer() const
{
	//	set up the return value
	CFStringRef theAnswer = NULL;
	
	//	set up the property address
	CAPropertyAddress theAddress(kAudioObjectPropertyManufacturer);
	
	//	make sure the property exists
	if(HasProperty(theAddress))
	{
		//	get the property data
		UInt32 theSize = sizeof(CFStringRef);
		GetPropertyData(theAddress, 0, NULL, theSize, &theAnswer);
	}
	
	return theAnswer;
}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// Control::GetVariant()
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	UInt32 Control::GetVariant() const
	{
		// Setup the answer
		CMIOObjectPropertyElement answer = GetClassID();
		
		// Setup the property address
		PropertyAddress address(kCMIOControlPropertyVariant);
		
		// Make sure the property exists
		if (HasProperty(address))
		{
			// Get the property data
			UInt32 dataUsed = 0;
			GetPropertyData(address, 0, NULL, sizeof(UInt32), dataUsed, &answer);
		}
		
		return answer;
	}
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	// Control::GetPropertyScope()
	//	Get the CMIOObjectPropertyScope IN THE OWNING CMIOObject that contains the control.  (Controls themselves only have kCMIOObjectPropertyScopeGlobal)
	//-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
	CMIOObjectPropertyScope Control::GetPropertyScope() const
	{
		// Setup the answer
		CMIOObjectPropertyScope answer = kCMIOObjectPropertyScopeGlobal;
		
		// Setup the property address
		PropertyAddress address(kCMIOControlPropertyScope);
		
		// Make sure the property exists
		if (HasProperty(address))
		{
			// Get the property data
			UInt32 dataUsed = 0;
			GetPropertyData(address, 0, NULL, sizeof(CMIOObjectPropertyScope), dataUsed, &answer);
		}
		
		return answer;
	}
Esempio n. 27
0
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;
}
Esempio n. 28
0
AudioDeviceID	CAAudioHardwareSystem::GetDefaultDevice(bool inIsInput, bool inIsSystem)
{
	AudioDeviceID theAnswer = 0;
	AudioHardwarePropertyID thePropertyID = 0;
	if(inIsInput)
	{
		thePropertyID = kAudioHardwarePropertyDefaultInputDevice;
	}
	else if(inIsSystem)
	{
		thePropertyID = kAudioHardwarePropertyDefaultSystemOutputDevice;
	}
	else
	{
		thePropertyID = kAudioHardwarePropertyDefaultOutputDevice;
	}
	UInt32 theSize = sizeof(AudioDeviceID);
	GetPropertyData(thePropertyID, theSize, &theAnswer);
	return theAnswer;
}
void	CAHALAudioObject::GetAllOwnedObjects(AudioClassID inClass, UInt32& ioNumberObjects, AudioObjectID* ioObjectIDs) const
{
	//	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
	UInt32 theDataSize = ioNumberObjects * sizeof(AudioClassID);
	GetPropertyData(theAddress, theQualifierSize, theQualifierData, theDataSize, ioObjectIDs);
	
	//	set the number of object IDs being returned
	ioNumberObjects = theDataSize / sizeof(AudioObjectID);
}
	UInt32 SelectorControl::GetItemIndexForID(UInt32 inItemID) const
	{
		UInt32 answer = 0xFFFFFFFF;	// Default to the featuring being on
		UInt32 numberOfItems = GetNumberItems();
		if (numberOfItems > 0)
		{
			CAAutoArrayDelete<UInt32> itemList(numberOfItems);
			UInt32 size = numberOfItems * sizeof(CMIODeviceID);
			UInt32 dataUsed = 0;
			GetPropertyData(PropertyAddress(kCMIOSelectorControlPropertyAvailableItems),0, NULL, size, dataUsed, itemList);
			for(UInt32 index = 0; index < numberOfItems; ++index)
			{
				if (inItemID == itemList[index])
				{
					answer = index;
					break;
				}
			}
		}
		return answer;
	}