Output: Add System Default Output option, rather than adjusting the listing to display the current system default only the first time

CQTexperiment
Christopher Snowhill 2021-12-05 22:49:56 -08:00
parent 554dde4e91
commit ed8a5763ab
2 changed files with 8 additions and 8 deletions

View File

@ -83,7 +83,6 @@ static OSStatus Sound_Renderer(void *inRefCon, AudioUnitRenderActionFlags *ioAc
OSStatus err;
if (deviceID == -1) {
DLog(@"DEVICE IS -1");
UInt32 size = sizeof(AudioDeviceID);
AudioObjectPropertyAddress theAddress = {
.mSelector = kAudioHardwarePropertyDefaultOutputDevice,

View File

@ -9,6 +9,12 @@
[self removeObjects:[self arrangedObjects]];
[self setSelectsInsertedObjects:NO];
NSDictionary *defaultDeviceInfo = @{
@"name": @"System Default Device",
@"deviceID": @(-1),
};
[self addObject:defaultDeviceInfo];
NSDictionary *defaultDevice = [[[NSUserDefaultsController sharedUserDefaultsController] defaults] objectForKey:@"outputDevice"];
NSString *defaultDeviceName = defaultDevice[@"name"];
@ -23,7 +29,7 @@
};
[self addObject:deviceInfo];
if (defaultDevice) {
if (defaultDevice && defaultDeviceID != -1) {
if ((deviceID == defaultDeviceID) ||
([deviceName isEqualToString:defaultDeviceName])) {
[self setSelectedObjects:[NSArray arrayWithObject:deviceInfo]];
@ -31,14 +37,9 @@
[[NSUserDefaults standardUserDefaults] setObject:deviceInfo forKey:@"outputDevice"];
}
}
else {
if (deviceID == systemDefaultID) {
[self setSelectedObjects:[NSArray arrayWithObject:deviceInfo]];
}
}
}];
if (!defaultDevice) {
if (!defaultDevice || defaultDeviceID == -1) {
[self setSelectionIndex:0];
}
}