From ed8a5763ab368fe16c30949d9f29e629120ae88a Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sun, 5 Dec 2021 22:49:56 -0800 Subject: [PATCH] Output: Add System Default Output option, rather than adjusting the listing to display the current system default only the first time --- Audio/Output/OutputCoreAudio.m | 1 - Preferences/Preferences/OutputsArrayController.m | 15 ++++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Audio/Output/OutputCoreAudio.m b/Audio/Output/OutputCoreAudio.m index fcb71560c..959f4d459 100644 --- a/Audio/Output/OutputCoreAudio.m +++ b/Audio/Output/OutputCoreAudio.m @@ -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, diff --git a/Preferences/Preferences/OutputsArrayController.m b/Preferences/Preferences/OutputsArrayController.m index 5db0766c1..306631027 100644 --- a/Preferences/Preferences/OutputsArrayController.m +++ b/Preferences/Preferences/OutputsArrayController.m @@ -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]; } }