Select device when preference window appears.
parent
b62c973ebc
commit
0d249ce0ff
|
@ -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,11 +40,21 @@
|
||||||
[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);
|
||||||
|
|
||||||
[self setSelectionIndex:0];
|
|
||||||
|
if (!defaultDevice)
|
||||||
|
[self setSelectionIndex:0];
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue