Пример #1
0
OSStatus	CAAudioChannelLayout::Save (CFPropertyListRef *outData) const 
{
	const AudioChannelLayout& layout = Layout();

	CACFDictionary dict (false);
	if (!dict.AddUInt32 (kACLTagKey, layout.mChannelLayoutTag))
		goto badadd;
	if (!dict.AddUInt32 (kACLBitmapKey, layout.mChannelBitmap))
		goto badadd;
	if (!dict.AddUInt32 (kACLDescKey, layout.mNumberChannelDescriptions))
		goto badadd;
	
	if (layout.mNumberChannelDescriptions)
	{	
		static char string[32];
		
		const AudioChannelDescription *desc = layout.mChannelDescriptions;
		for (unsigned int i = 0; i < layout.mNumberChannelDescriptions; ++i, ++desc) 
		{
			CACFDictionary descDict (true);
			sprintf (string, "%d", i);
			if (!descDict.AddUInt32 (kACLLabelKey, desc->mChannelLabel))
				goto badadd;
			if (!descDict.AddUInt32 (kACLFlagsKey, desc->mChannelFlags))
				goto badadd;
			if (!descDict.AddFloat32 (kACLCoords0Key, desc->mCoordinates[0]))
				goto badadd;
			if (!descDict.AddFloat32 (kACLCoords1Key, desc->mCoordinates[1]))
				goto badadd;
			if (!descDict.AddFloat32 (kACLCoords2Key, desc->mCoordinates[2]))
				goto badadd;
			if (!dict.AddCFTypeWithCStringKey (string, descDict.GetDict()))
				goto badadd;
		}
	}
	
	*outData = dict.GetDict();	
	
	return noErr;
	
badadd:
	dict.ShouldRelease(true);
	return -1;
}
Пример #2
0
OSStatus	CAAudioChannelLayout::Save (CFPropertyListRef *outData) const 
{
	const AudioChannelLayout& layout = Layout();

	CACFDictionary dict (false);
	if (!dict.AddUInt32 (kACLTagKey, layout.mChannelLayoutTag))
		goto badadd;
	if (layout.mChannelBitmap && !dict.AddUInt32 (kACLBitmapKey, layout.mChannelBitmap))
		goto badadd;
	
	if (layout.mNumberChannelDescriptions)
	{	
		CFMutableArrayRef descs = CFArrayCreateMutable (NULL, layout.mNumberChannelDescriptions, &kCFTypeArrayCallBacks);
		
		const AudioChannelDescription *desc = layout.mChannelDescriptions;
		for (unsigned int i = 0; i < layout.mNumberChannelDescriptions; ++i, ++desc) 
		{
			CACFDictionary descDict (true);
			if (!descDict.AddUInt32 (kACLLabelKey, desc->mChannelLabel))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddUInt32 (kACLFlagsKey, desc->mChannelFlags))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddFloat32 (kACLCoords0Key, desc->mCoordinates[0]))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddFloat32 (kACLCoords1Key, desc->mCoordinates[1]))
				{ CFRelease (descs); goto badadd; }
			if (!descDict.AddFloat32 (kACLCoords2Key, desc->mCoordinates[2]))
				{ CFRelease (descs); goto badadd; }
			
			CFArrayAppendValue (descs, descDict.AsPropertyList());
		}
		dict.AddArray (kACLDescsKey, descs);
		
		CFRelease (descs);
	}
	
	*outData = dict.GetDict();	
	
	return noErr;
	
badadd:
	dict.ShouldRelease(true);
	return paramErr;
}
Пример #3
0
void		CAAUMIDIMap::SaveAsMapPList (AudioUnit inUnit, const AUParameterMIDIMapping* inMappings, UInt32 inNumMappings, CFPropertyListRef &outData, CFStringRef inName)
{

	CACFDictionary mappingDict (false);	
	CACFArray maps (true);
	
	for (UInt32 i = 0; i< inNumMappings; ++i) 
	{
		CFPropertyListRef data;
		CAAUMIDIMap paramMap(inMappings[i]);
		paramMap.Save (data);
		if (data) 
		{
			maps.AppendCFType (data); 
			CFRelease(data); 
		}				
	}

	if (maps.GetNumberItems()) {
		mappingDict.AddCFType (kParamMIDIStr, maps.GetCFArray());
		
		// Add the AU info here - where this map came from
		CAAudioUnit au (inUnit);
		CFPropertyListRef data;
		au.Comp().Save (&data);
		
		mappingDict.AddCFType (kAUStr, data);
		CFRelease(data);
		
		if (!inName) inName = CFSTR("Untitled");
		mappingDict.AddString (CFSTR("name"), inName);
		
		mappingDict.AddUInt32 (CFSTR("version"), 1);
		
		outData = mappingDict.AsPropertyList();
	} else {
		mappingDict.ShouldRelease(true);
		outData = NULL;
	}
}