Output: Add System Default Output option, rather than adjusting the listing to display the current system default only the first time
parent
554dde4e91
commit
ed8a5763ab
|
@ -83,7 +83,6 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
|
||||||
OSStatus err;
|
OSStatus err;
|
||||||
|
|
||||||
if (deviceID == -1) {
|
if (deviceID == -1) {
|
||||||
DLog(@"DEVICE IS -1");
|
|
||||||
UInt32 size = sizeof(AudioDeviceID);
|
UInt32 size = sizeof(AudioDeviceID);
|
||||||
AudioObjectPropertyAddress theAddress = {
|
AudioObjectPropertyAddress theAddress = {
|
||||||
.mSelector = kAudioHardwarePropertyDefaultOutputDevice,
|
.mSelector = kAudioHardwarePropertyDefaultOutputDevice,
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
|
|
||||||
[self setSelectsInsertedObjects:NO];
|
[self setSelectsInsertedObjects:NO];
|
||||||
|
|
||||||
|
NSDictionary *defaultDeviceInfo = @{
|
||||||
|
@"name": @"System Default Device",
|
||||||
|
@"deviceID": @(-1),
|
||||||
|
};
|
||||||
|
[self addObject:defaultDeviceInfo];
|
||||||
|
|
||||||
NSDictionary *defaultDevice = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"outputDevice"];
|
NSDictionary *defaultDevice = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"outputDevice"];
|
||||||
NSString *defaultDeviceName = defaultDevice[@"name"];
|
NSString *defaultDeviceName = defaultDevice[@"name"];
|
||||||
NSNumber *defaultDeviceIDNum = defaultDevice[@"deviceID"];
|
NSNumber *defaultDeviceIDNum = defaultDevice[@"deviceID"];
|
||||||
|
@ -23,7 +29,7 @@
|
||||||
};
|
};
|
||||||
[self addObject:deviceInfo];
|
[self addObject:deviceInfo];
|
||||||
|
|
||||||
if (defaultDevice) {
|
if (defaultDevice && defaultDeviceID != -1) {
|
||||||
if ((deviceID == defaultDeviceID) ||
|
if ((deviceID == defaultDeviceID) ||
|
||||||
([deviceName isEqualToString:defaultDeviceName])) {
|
([deviceName isEqualToString:defaultDeviceName])) {
|
||||||
[self setSelectedObjects:[NSArray arrayWithObject:deviceInfo]];
|
[self setSelectedObjects:[NSArray arrayWithObject:deviceInfo]];
|
||||||
|
@ -31,14 +37,9 @@
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:deviceInfo forKey:@"outputDevice"];
|
[[NSUserDefaults standardUserDefaults] setObject:deviceInfo forKey:@"outputDevice"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if (deviceID == systemDefaultID) {
|
|
||||||
[self setSelectedObjects:[NSArray arrayWithObject:deviceInfo]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
if (!defaultDevice) {
|
if (!defaultDevice || defaultDeviceID == -1) {
|
||||||
[self setSelectionIndex:0];
|
[self setSelectionIndex:0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue