• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: aggregate device
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: aggregate device


  • Subject: Re: aggregate device
  • From: Jeff Moore <email@hidden>
  • Date: Mon, 17 Apr 2006 12:42:41 -0700


On Apr 14, 2006, at 7:00 PM, Christoph Teschner wrote:

Hi,

I have been trying to create an aggregate following the steps I have read from previous posts. After having located the base plug- in, I create a cfdictionary representing the aggregate, however, when I tell the base plug in to create the aggregate with kAudioPlugInCreateAggregateDevice in AudioObjectGetPropertyData I get an Error.
I've put some sample code below in which I try to create an aggregate. Since, I wasn't able to find much documentation for this, I'd really appreciate any further help on this issue or if someone can see what I'm missing and/or doing wrong in my code.


thanks so much in advance,
christoph

// 1. locate the base plug-in using ...

	UInt32 theSize;
	AudioValueTranslation theTranslation;
	CFStringRef theCFString;
	AudioDeviceID theID; // necessary for further programming

theCFString = CFStringCreateWithCString (NULL,"com.apple.audio.CoreAudio",kCFStringEncodingUTF8);

theTranslation.mInputData = &theCFString;
theTranslation.mInputDataSize = sizeof(CFStringRef);
theTranslation.mOutputData = &theID;
theTranslation.mOutputDataSize = sizeof(AudioDeviceID);
theSize = sizeof(AudioValueTranslation);
result = AudioHardwareGetProperty ( kAudioHardwarePropertyPlugInForBundleID, &theSize,
&theTranslation );

This is correct.

// 2. Create a CFDictionary that describes the aggregate device you want to create...
// the keys are in <CoreAudio/AudioHardware.h> -> unique UID



// For testing purposes I only use the built-in as the only subdevice

CFMutableDictionaryRef newDictionary = CFDictionaryCreateMutable (kCFAllocatorDefault,0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);

CFDictionarySetValue(newDictionary, CFSTR( "uid" ),CFSTR ( "ExampleAggregate" ));
CFDictionarySetValue(newDictionary, CFSTR( "name" ),CFSTR ( "ExampleAggregate" ));

This is also correct.


CFMutableArrayRef newArray = CFArrayCreateMutable(NULL,0,NULL);
CFMutableDictionaryRef subdevice1;
result = AudioDeviceGetProperty(builtInDeviceId,0,NO, kAudioAggregateDevicePropertyComposition, & ioPropertyDataSize,& subdevice1);

This is not correct and you should be getting an error here. kAudioAggregateDevicePropertyComposition is a property that only exists for actual aggregate devices.




	CFArrayAppendValue(newArray,subdevice1);
	CFDictionarySetValue(newDictionary, CFSTR( "subdevices" ), newArray);

My guess is that you are attempting to make an array to hold the UID's of the sub-devices for your new aggregate. You have it right for creating the array and putting it in the dictionary, but you need to get the UID from the regular built-in device.



// 3. Tell the base plug-in to create the aggregate device using
//		kAudioPlugInCreateAggregateDevice.

	UInt32 outDataSize;

	AudioObjectPropertyAddress theAddress;
	theAddress.mSelector = kAudioPlugInCreateAggregateDevice;
	theAddress.mScope = kAudioObjectPropertyScopeGlobal;
	theAddress.mElement = kAudioObjectPropertyElementMaster;

result = AudioObjectGetPropertyDataSize(theID, &theAddress, 0, NULL, &outDataSize);

There really isn't any need to get the size of the value for kAudioPlugInCreateAggregateDevice. It's always going to be sizeof (CFDictionaryRef).



	AudioObjectID theNewPsoidoID;

//UInt32 inQualifierDataSize = 0; //do I actually have to provide the size here? I could not find any function to retrieve the size of CFDictionaryRef

result = AudioObjectGetPropertyData(theID, &theAddress, 0, &myDict, &outDataSize, &theNewPsoidoID); // this fails

What error are you getting? My guess is that your are getting kAudioHardwareBadPropertySizeError because the qualifier size is set to zero rather than sizeof(CFDictionaryRef).


Note that there is a bug in the HAL with respect to creating aggregate devices. The bug is that the HAL will fail to fully create the aggregate device when you pass a non-empty array of sub-devices in the configuration dictionary. The work around is relatively straight forward. You first create the aggregate device more or less as you have it here, except that you don't include the array of sub- devices in the dictionary. After the aggregate is created, you use kAudioAggregateDevicePropertyFullSubDeviceList and kAudioAggregateDevicePropertyMasterSubDevice to configure the devices to be aggregated.

--

Jeff Moore
Core Audio
Apple


_______________________________________________ Do not post admin requests to the list. They will be ignored. Coreaudio-api mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: aggregate device
      • From: "Christoph Teschner" <email@hidden>
References: 
 >aggregate device (From: "Christoph Teschner" <email@hidden>)

  • Prev by Date: Re: Is the documentation for SDK 1.4.3 available without installation?
  • Next by Date: Re: Is the documentation for SDK 1.4.3 available without installation?
  • Previous by thread: aggregate device
  • Next by thread: Re: aggregate device
  • Index(es):
    • Date
    • Thread