Select device when preference window appears.

CQTexperiment
vspader 2007-02-20 02:08:37 +00:00
parent b62c973ebc
commit 0d249ce0ff
1 changed files with 14 additions and 1 deletions

View File

@ -17,6 +17,9 @@
verify_noerr(AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propsize, devids)); verify_noerr(AudioHardwareGetProperty(kAudioHardwarePropertyDevices, &propsize, devids));
int i; int i;
NSLog(@"Number of devices: %d", nDevices); NSLog(@"Number of devices: %d", nDevices);
NSDictionary *defaultDevice = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"outputDevice"];
for (i = 0; i < nDevices; ++i) { for (i = 0; i < nDevices; ++i) {
char name[64]; char name[64];
UInt32 maxlen = 64; UInt32 maxlen = 64;
@ -37,10 +40,20 @@
[NSNumber numberWithLong:devids[i]], @"deviceID", [NSNumber numberWithLong:devids[i]], @"deviceID",
nil]; nil];
[self addObject:deviceInfo]; [self addObject:deviceInfo];
if (defaultDevice) {
if ([[defaultDevice objectForKey:@"deviceID"] isEqualToNumber:[deviceInfo objectForKey:@"deviceID"]]) {
[self setSelectedObjects:[NSArray arrayWithObject:deviceInfo]];
NSLog(@"Selected default!");
}
}
[deviceInfo release]; [deviceInfo release];
} }
free(devids); free(devids);
if (!defaultDevice)
[self setSelectionIndex:0]; [self setSelectionIndex:0];
} }