• 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: Trouble setting sub device list, with a private aggregate device
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Trouble setting sub device list, with a private aggregate device


  • Subject: Re: Trouble setting sub device list, with a private aggregate device
  • From: Neil Clayton <email@hidden>
  • Date: Wed, 12 Jul 2006 17:38:54 +1200

I've put a breakpoint on the code that deletes it - and it's certainly not being called. There's only a single process, and that's not getting killed either.

So I created another project, with the smallest amount of code to demonstrate the problem.
The output (when attempting to create a private aggregate) is:
2006-07-12 16:19:26.387 CreateAggregate[4284] Created aggreate with ID 283 - dumping device list immediately
2006-07-12 16:19:26.389 CreateAggregate[4284] Device 3 is <MTCoreAudioDevice: 0x31d6e0 id 283> Monitoring-Aggregate


Here, you can see the device being created. The call to dump the device information is being made right at the end of the creation method. - but the device 'disappears' after that method completes. The timer is running, but no further information is shown. As a note, I've commented out the conditional in the dumpDevices method to dump everything, and there is no other unnamed or other Aggregate Device present.

When I change the aggregate to be public I get the output:
2006-07-12 16:20:31.817 CreateAggregate[4303] Created aggreate with ID 283 - dumping device list immediately
2006-07-12 16:20:31.818 CreateAggregate[4303] Device 3 is <MTCoreAudioDevice: 0x307950 id 283> Monitoring-Aggregate
2006-07-12 16:20:32.343 CreateAggregate[4303] Device 3 is <MTCoreAudioDevice: 0x36b1e0 id 283> Monitoring-Aggregate
2006-07-12 16:20:33.343 CreateAggregate[4303] Device 3 is <MTCoreAudioDevice: 0x31ed80 id 283> Monitoring-Aggregate
2006-07-12 16:20:34.342 CreateAggregate[4303] Device 3 is <MTCoreAudioDevice: 0x31ed80 id 283> Monitoring-Aggregate


e.g: you can see that the timer is running, and showing that the device does exist.
So it seems that either I've setup the aggregate incorrectly or found some bug. The later would seem a little odd as I would have thought what I'm doing is not that unusual.


Any ideas?

Code is as follows:

#import "AggregateUIController.h"

@implementation AggregateUIController

- (void) dumpDevices {
	NSArray *devices = [MTCoreAudioDevice allDevices];
	int index = 0;
	for(index = 0; index < [devices count]; index++) {
		MTCoreAudioDevice *device = [devices objectAtIndex:index];
		NSRange range = [[device deviceName] rangeOfString:@"Monitoring"];
		if(range.location != NSNotFound) {
			NSLog(@"Device %d is %@", index, device);
		}
	}
}

- (void) monitorDevices:(NSTimer*)timer {
	[self dumpDevices];
}

- (void) awakeFromNib {
[NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(monitorDevices:) userInfo:nil repeats:YES];
}


- (AudioDeviceID) basePlugin {
OSStatus err;
UInt32 theSize;
CFStringRef theCFString = CFStringCreateWithCString (NULL, "com.apple.audio.CoreAudio", kCFStringEncodingUTF8);
AudioDeviceID theID;
AudioValueTranslation theTranslation;
theTranslation.mInputData = &theCFString;
theTranslation.mInputDataSize = sizeof(CFStringRef);
theTranslation.mOutputData = &theID;
theTranslation.mOutputDataSize = sizeof(AudioDeviceID);
theSize = sizeof(AudioValueTranslation);
BAILSETERR( AudioHardwareGetProperty ( kAudioHardwarePropertyPlugInForBundleID, &theSize, &theTranslation) );
bail:
if(err) {
[NSException raise:@"BasePlugin" format:@"Unable to get base plugin, error %d", err];
}
return theID;
}


- (void) createAggregate {
	OSStatus err;
	AudioDeviceID theID = [self basePlugin];

	NSMutableDictionary *newDictionary = [NSMutableDictionary new];
	[newDictionary setObject:@"Monitoring-Aggregate" forKey:@"uid"];
	[newDictionary setObject:@"Monitoring-Aggregate" forKey:@"name"];
	[newDictionary setObject:[NSNumber numberWithInt:1] forKey:@"private"];

UInt32 outDataSize;
AudioObjectPropertyAddress theAddress;
theAddress.mSelector = kAudioPlugInCreateAggregateDevice;
theAddress.mScope = kAudioObjectPropertyScopeGlobal;
theAddress.mElement = kAudioObjectPropertyElementMaster;
BAILSETERR ( AudioObjectGetPropertyDataSize(theID, &theAddress, 0, NULL, &outDataSize) );


BAILSETERR( AudioObjectGetPropertyData(theID, &theAddress, sizeof (CFDictionaryRef), &newDictionary, &outDataSize, &aggregate) );

NSLog(@"Created aggreate with ID %i - dumping device list immediately", aggregate);
[self dumpDevices];
bail:
if(err) {
[NSException raise:@"CannotCreateAggregte" format:@"Unable to create the aggregate device, error %d", err];
}
}


- (IBAction) createAggregateDevice:(id)sender {
	[self createAggregate];
}

@end



On 12/07/2006, at 9:43 AM, Jeff Moore wrote:

Private aggregates go away when the process that created them dies or when they are explicitly deleted. There aren't any other ways to get rid of them.

On Jul 11, 2006, at 2:32 PM, Neil Clayton wrote:

OK, that seems to make sense. Thanks.

I added some code directly after the creation to enumerate all the devices. Sure enough, when I do the same thing before the method that's failing, the device isn't there. It's as though upon returning to the app's main run loop, it's disappeared.

When created automatically, what causes an aggregate to be removed? Is there some property I have to set in order for it to become persistent (for longer)?

Neil

On 12/07/2006, at 6:20 AM, Jeff Moore wrote:

HAL error codes are easier to read if you look at them as 4CCs. In this case, 560947818 == '!obj' == kAudioHardwareBadObjectError. This error is only ever returned when the AudioObjectID you pass to an API call is invalid.

On Jul 10, 2006, at 10:17 PM, Neil Clayton wrote:

As I understand it (from reading previous posts) all I need to do in order to make an aggregate device private, is the following:

NSMutableDictionary *newDictionary = [NSMutableDictionary new];
[newDictionary setObject:@"iShowUMonitoring-Aggregate" forKey:@"uid"];
[newDictionary setObject:@"iShowUMonitoring-Aggregate" forKey:@"name"];
[newDictionary setObject:[NSNumber numberWithInt:1] forKey:@"private"];


--

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:
40cloudnine.net.nz


This email sent to email@hidden

_______________________________________________ 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: Trouble setting sub device list, with a private aggregate device
      • From: Jeff Moore <email@hidden>
References: 
 >Trouble setting sub device list, with a private aggregate device (From: Neil Clayton <email@hidden>)
 >Re: Trouble setting sub device list, with a private aggregate device (From: Jeff Moore <email@hidden>)
 >Re: Trouble setting sub device list, with a private aggregate device (From: Neil Clayton <email@hidden>)
 >Re: Trouble setting sub device list, with a private aggregate device (From: Jeff Moore <email@hidden>)

  • Prev by Date: Re: looking for AU instrument writer's guide
  • Next by Date: Re: newbie AU questions
  • Previous by thread: Re: Trouble setting sub device list, with a private aggregate device
  • Next by thread: Re: Trouble setting sub device list, with a private aggregate device
  • Index(es):
    • Date
    • Thread