Re: aggregate device
Re: aggregate device
- Subject: Re: aggregate device
- From: Jeff Moore <email@hidden>
- Date: Mon, 1 May 2006 12:06:32 -0700
You are making a very bad assumption that the first device in the
device list is the built-in device. As you are finding out, this is
not the case. The order that devices appear in the device list should
be considered random and you should not be relying on it. The only
way to find the device you are looking for is to actually iterate
through the device list and query each device to see if it meets your
criteria.
On Apr 29, 2006, at 12:06 PM, Christoph Teschner wrote:
Jeff,
thanks a lot for your help.
I was able to remove the mistakes I've made in my code and I've
done the work around you suggested in order to create the aggregate
device.
I am no longer getting any errors, however I'm not sure if
everything is working as it should be. The newly generated
aggregate device appears in Audio MIDI Setup, but it still has 0 In
and Out channels and the Build-In Audio is not selected for use
(instead an unnamed device without channels is selected for use).
Any further advice would be great.
thanks again,
Christoph
This is the newly modified code:
// 2. Create a CFDictionary that describes the aggregate device
you want to create...
// the keys are in <CoreAudio/AudioHardware.h> -> unique UID
CFMutableDictionaryRef myDict = CFDictionaryCreateMutable
(kCFAllocatorDefault,0, &kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
CFDictionarySetValue(myDict, CFSTR( "uid" ),CFSTR
( "ChristophAggregate2" ));
CFDictionarySetValue(myDict, CFSTR( "name" ),CFSTR
( "ChristophAggregate2" ));
SInt32 privateKey = 0;
CFDictionarySetValue(myDict, CFSTR( "private" ),CFNumberCreate
(NULL, kCFNumberSInt32Type, &privateKey));
// 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);
AudioObjectID theNewPsoidoID;
result = AudioObjectGetPropertyData(theID, &theAddress, sizeof
(CFDictionaryRef), &myDict, &outDataSize, &theNewPsoidoID);
if(result != kAudioHardwareNoError) NSLog
(@"AudioObjectGetPropertyData error");
//get list of all audio devices -> Build-In Audio is in deviceList[0]
int numDevices;
AudioDeviceID * deviceList;
AudioHardwareGetPropertyInfo ( kAudioHardwarePropertyDevices,
&theSize, NULL );
numDevices = theSize / sizeof(AudioDeviceID);
deviceList = (AudioDeviceID *) malloc ( theSize );
AudioHardwareGetProperty ( kAudioHardwarePropertyDevices,
&theSize, deviceList );
//workaround: kAudioAggregateDevicePropertyFullSubDeviceList
CFMutableArrayRef mySubDeviceList = CFArrayCreateMutable(NULL,
0,NULL);
CFStringRef mySubdevice = CFStringCreateWithFormat(NULL, NULL,
CFSTR("%i"), deviceList[0]);
CFArrayAppendValue(mySubDeviceList,mySubdevice);
theAddress.mSelector =
kAudioAggregateDevicePropertyFullSubDeviceList;
theAddress.mScope = kAudioObjectPropertyScopeGlobal;
theAddress.mElement = kAudioObjectPropertyElementMaster;
result = AudioObjectSetPropertyData(theNewPsoidoID, &theAddress,
0,NULL,sizeof(CFArrayRef), &mySubDeviceList);
if(result != kAudioHardwareNoError) NSLog
(@"AudioObjectGetPropertyData error");
//workaround kAudioAggregateDevicePropertyMasterSubDevice
CFStringRef myMasterSubdevice = CFStringCreateWithFormat(NULL,
NULL, CFSTR("%i"), deviceList[0]);
theAddress.mSelector = kAudioAggregateDevicePropertyMasterSubDevice;
theAddress.mScope = kAudioObjectPropertyScopeGlobal;
theAddress.mElement = kAudioObjectPropertyElementMaster;
result = AudioObjectSetPropertyData(theNewPsoidoID, &theAddress,
0,NULL,sizeof(CFStringRef), &myMasterSubdevice);
if(result != kAudioHardwareNoError) NSLog
(@"AudioObjectGetPropertyData error");
--
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