diff --git a/BGMApp/BGMApp.xcodeproj/project.pbxproj b/BGMApp/BGMApp.xcodeproj/project.pbxproj index 213e7ba..2f26874 100644 --- a/BGMApp/BGMApp.xcodeproj/project.pbxproj +++ b/BGMApp/BGMApp.xcodeproj/project.pbxproj @@ -108,7 +108,7 @@ 1CD9894F1ECFFCFC0014BBBF /* BGMPreferencesMenu.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C0BD0A71BF1B029004F4CF5 /* BGMPreferencesMenu.mm */; }; 1CD989501ECFFCFC0014BBBF /* BGMAboutPanel.m in Sources */ = {isa = PBXBuildFile; fileRef = 27D1D6BA1DD7226C0049E707 /* BGMAboutPanel.m */; }; 1CD989511ECFFCFC0014BBBF /* BGMAutoPauseMusicPrefs.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1C0BD0A41BF1A8E6004F4CF5 /* BGMAutoPauseMusicPrefs.mm */; }; - 1CD989521ECFFCFC0014BBBF /* BGMOutputDevicePrefs.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CE7064B1BF1EC0600BFC06D /* BGMOutputDevicePrefs.mm */; }; + 1CD989521ECFFCFC0014BBBF /* BGMOutputDeviceMenuSection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CE7064B1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.mm */; }; 1CD989531ECFFCFC0014BBBF /* BGMDeviceControlSync.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C46994C1BD7694C00F78043 /* BGMDeviceControlSync.cpp */; }; 1CD989541ECFFCFC0014BBBF /* BGMPlayThrough.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C1962E51BC94E91008A4DF7 /* BGMPlayThrough.cpp */; }; 1CD989551ECFFCFC0014BBBF /* BGMUserDefaults.m in Sources */ = {isa = PBXBuildFile; fileRef = 2743C9F01D853FBB0089613B /* BGMUserDefaults.m */; }; @@ -117,7 +117,7 @@ 1CD989581ECFFD250014BBBF /* CAMutex.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C1963041BCAF468008A4DF7 /* CAMutex.cpp */; }; 1CD989591ECFFD250014BBBF /* CAPThread.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C8034C21BDAFD5700668E00 /* CAPThread.cpp */; }; 1CD9895A1ECFFD250014BBBF /* CARingBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C1962E21BC94E15008A4DF7 /* CARingBuffer.cpp */; }; - 1CE7064C1BF1EC0600BFC06D /* BGMOutputDevicePrefs.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CE7064B1BF1EC0600BFC06D /* BGMOutputDevicePrefs.mm */; }; + 1CE7064C1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.mm in Sources */ = {isa = PBXBuildFile; fileRef = 1CE7064B1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.mm */; }; 1CEACF4D1F34793700FEC143 /* CAHALAudioDevice.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C1962EB1BCABFC5008A4DF7 /* CAHALAudioDevice.cpp */; }; 1CEACF4F1F34A30000FEC143 /* Mock_CAHALAudioSystemObject.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CEACF4E1F34A30000FEC143 /* Mock_CAHALAudioSystemObject.cpp */; }; 1CED61691C3081C2002CAFCF /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 1CED61681C3081C2002CAFCF /* LICENSE */; }; @@ -300,8 +300,8 @@ 1CD1FD2F1BDDEAF2004F7E1B /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 1CD410D21F9EDDAD0070A094 /* BGMAppVolumesController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BGMAppVolumesController.h; sourceTree = ""; }; 1CD410D31F9EDDAD0070A094 /* BGMAppVolumesController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BGMAppVolumesController.mm; sourceTree = ""; }; - 1CE7064A1BF1EC0600BFC06D /* BGMOutputDevicePrefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BGMOutputDevicePrefs.h; sourceTree = ""; }; - 1CE7064B1BF1EC0600BFC06D /* BGMOutputDevicePrefs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BGMOutputDevicePrefs.mm; sourceTree = ""; }; + 1CE7064A1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BGMOutputDeviceMenuSection.h; sourceTree = ""; }; + 1CE7064B1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BGMOutputDeviceMenuSection.mm; sourceTree = ""; }; 1CEACF4E1F34A30000FEC143 /* Mock_CAHALAudioSystemObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mock_CAHALAudioSystemObject.cpp; path = UnitTests/Mock_CAHALAudioSystemObject.cpp; sourceTree = ""; }; 1CED61681C3081C2002CAFCF /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; }; 1CED616A1C316E1A002CAFCF /* BGMAudioDeviceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BGMAudioDeviceManager.h; sourceTree = ""; }; @@ -571,8 +571,8 @@ 1C1465B71BCC3A73003AEFE6 /* BGMAutoPauseMusic.mm */, 1C4699451BD5BF2E00F78043 /* Music Players */, 1C0BD0A21BF1A827004F4CF5 /* Preferences Menu */, - 1CE7064A1BF1EC0600BFC06D /* BGMOutputDevicePrefs.h */, - 1CE7064B1BF1EC0600BFC06D /* BGMOutputDevicePrefs.mm */, + 1CE7064A1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.h */, + 1CE7064B1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.mm */, 1C46994D1BD7694C00F78043 /* BGMDeviceControlSync.h */, 1C46994C1BD7694C00F78043 /* BGMDeviceControlSync.cpp */, 1C3D36711ED90E8600F98E66 /* BGMDeviceControlsList.h */, @@ -972,7 +972,7 @@ 1C3DB4891BE0885A00EC8160 /* BGMAppVolumes.m in Sources */, 1C0BD0A51BF1A8E6004F4CF5 /* BGMAutoPauseMusicPrefs.mm in Sources */, 1C1963061BCAF468008A4DF7 /* CAMutex.cpp in Sources */, - 1CE7064C1BF1EC0600BFC06D /* BGMOutputDevicePrefs.mm in Sources */, + 1CE7064C1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.mm in Sources */, 1CACCF391F3175AD007F86CA /* BGMBackgroundMusicDevice.cpp in Sources */, 1C1962F51BCABFC5008A4DF7 /* CAHALAudioStream.cpp in Sources */, 1C46994E1BD7694C00F78043 /* BGMDeviceControlSync.cpp in Sources */, @@ -1039,7 +1039,7 @@ 1CD9894F1ECFFCFC0014BBBF /* BGMPreferencesMenu.mm in Sources */, 1CD989501ECFFCFC0014BBBF /* BGMAboutPanel.m in Sources */, 1CD989511ECFFCFC0014BBBF /* BGMAutoPauseMusicPrefs.mm in Sources */, - 1CD989521ECFFCFC0014BBBF /* BGMOutputDevicePrefs.mm in Sources */, + 1CD989521ECFFCFC0014BBBF /* BGMOutputDeviceMenuSection.mm in Sources */, 1CD989531ECFFCFC0014BBBF /* BGMDeviceControlSync.cpp in Sources */, 1CD989541ECFFCFC0014BBBF /* BGMPlayThrough.cpp in Sources */, 1CD989551ECFFCFC0014BBBF /* BGMUserDefaults.m in Sources */, diff --git a/BGMApp/BGMApp/BGMAppDelegate.mm b/BGMApp/BGMApp/BGMAppDelegate.mm index d513849..a12b0bf 100644 --- a/BGMApp/BGMApp/BGMAppDelegate.mm +++ b/BGMApp/BGMApp/BGMAppDelegate.mm @@ -29,7 +29,7 @@ #import "BGMAutoPauseMusic.h" #import "BGMAutoPauseMenuItem.h" #import "BGMMusicPlayers.h" -#import "BGMOutputDevicePrefs.h" +#import "BGMOutputDeviceMenuSection.h" #import "BGMOutputVolumeMenuItem.h" #import "BGMPreferencesMenu.h" #import "BGMPreferredOutputDevices.h" @@ -62,7 +62,7 @@ static NSString* const kOptShowDockIcon = @"--show-dock-icon"; BGMMusicPlayers* musicPlayers; BGMSystemSoundsVolume* systemSoundsVolume; BGMAppVolumesController* appVolumes; - BGMOutputDevicePrefs* outputDevicePrefs; + BGMOutputDeviceMenuSection* outputDeviceMenuSection; BGMPreferencesMenu* prefsMenu; BGMXPCListener* xpcListener; BGMPreferredOutputDevices* preferredOutputDevices; @@ -295,10 +295,11 @@ static NSString* const kOptShowDockIcon = @"--show-dock-icon"; [self initVolumesMenuSection]; // Output device selection. - outputDevicePrefs = [[BGMOutputDevicePrefs alloc] initWithBGMMenu:self.bgmMenu - audioDevices:audioDevices - preferredDevices:preferredOutputDevices]; - [audioDevices setOutputDevicePrefs:outputDevicePrefs]; + outputDeviceMenuSection = + [[BGMOutputDeviceMenuSection alloc] initWithBGMMenu:self.bgmMenu + audioDevices:audioDevices + preferredDevices:preferredOutputDevices]; + [audioDevices setOutputDeviceMenuSection:outputDeviceMenuSection]; // Preferences submenu. prefsMenu = [[BGMPreferencesMenu alloc] initWithBGMMenu:self.bgmMenu diff --git a/BGMApp/BGMApp/BGMAudioDeviceManager.h b/BGMApp/BGMApp/BGMAudioDeviceManager.h index 8ac82bf..382bddd 100644 --- a/BGMApp/BGMApp/BGMAudioDeviceManager.h +++ b/BGMApp/BGMApp/BGMAudioDeviceManager.h @@ -39,7 +39,7 @@ // Forward Declarations @class BGMOutputVolumeMenuItem; -@class BGMOutputDevicePrefs; +@class BGMOutputDeviceMenuSection; #pragma clang assume_nonnull begin @@ -55,8 +55,8 @@ static const int kBGMErrorCode_ReturningEarly = 2; // Set the BGMOutputVolumeMenuItem to be notified when the output device is changed. - (void) setOutputVolumeMenuItem:(BGMOutputVolumeMenuItem*)item; -// Set the BGMOutputDevicePrefs to be notified when the output device is changed. -- (void) setOutputDevicePrefs:(BGMOutputDevicePrefs*)prefs; +// Set the BGMOutputDeviceMenuSection to be notified when the output device is changed. +- (void) setOutputDeviceMenuSection:(BGMOutputDeviceMenuSection*)menuSection; // Set BGMDevice as the default audio device for all processes - (NSError* __nullable) setBGMDeviceAsOSDefault; diff --git a/BGMApp/BGMApp/BGMAudioDeviceManager.mm b/BGMApp/BGMApp/BGMAudioDeviceManager.mm index f73624d..8f3003a 100644 --- a/BGMApp/BGMApp/BGMAudioDeviceManager.mm +++ b/BGMApp/BGMApp/BGMAudioDeviceManager.mm @@ -28,7 +28,7 @@ #import "BGM_Utils.h" #import "BGMAudioDevice.h" #import "BGMDeviceControlSync.h" -#import "BGMOutputDevicePrefs.h" +#import "BGMOutputDeviceMenuSection.h" #import "BGMOutputVolumeMenuItem.h" #import "BGMPlayThrough.h" #import "BGMXPCProtocols.h" @@ -61,7 +61,7 @@ NSXPCConnection* __nullable bgmXPCHelperConnection; BGMOutputVolumeMenuItem* __nullable outputVolumeMenuItem; - BGMOutputDevicePrefs* __nullable outputDevicePrefs; + BGMOutputDeviceMenuSection* __nullable outputDeviceMenuSection; NSRecursiveLock* stateLock; } @@ -73,7 +73,7 @@ stateLock = [NSRecursiveLock new]; bgmXPCHelperConnection = nil; outputVolumeMenuItem = nil; - outputDevicePrefs = nil; + outputDeviceMenuSection = nil; outputDevice = kAudioObjectUnknown; try { @@ -105,8 +105,8 @@ outputVolumeMenuItem = item; } -- (void) setOutputDevicePrefs:(BGMOutputDevicePrefs*)prefs { - outputDevicePrefs = prefs; +- (void) setOutputDeviceMenuSection:(BGMOutputDeviceMenuSection*)menuSection { + outputDeviceMenuSection = menuSection; } #pragma mark Systemwide Default Device @@ -331,7 +331,7 @@ // Update the menu item for the volume of the output device. [outputVolumeMenuItem outputDeviceDidChange]; - [outputDevicePrefs outputDeviceDidChange]; + [outputDeviceMenuSection outputDeviceDidChange]; } - (NSError*) failedToSetOutputDevice:(AudioDeviceID)deviceID diff --git a/BGMApp/BGMApp/BGMOutputDevicePrefs.h b/BGMApp/BGMApp/BGMOutputDeviceMenuSection.h similarity index 94% rename from BGMApp/BGMApp/BGMOutputDevicePrefs.h rename to BGMApp/BGMApp/BGMOutputDeviceMenuSection.h index ef866d2..6f04deb 100644 --- a/BGMApp/BGMApp/BGMOutputDevicePrefs.h +++ b/BGMApp/BGMApp/BGMOutputDeviceMenuSection.h @@ -14,7 +14,7 @@ // along with Background Music. If not, see . // -// BGMOutputDevicePrefs.h +// BGMOutputDeviceMenuSection.h // BGMApp // // Copyright © 2016, 2018 Kyle Neideck @@ -30,7 +30,7 @@ #pragma clang assume_nonnull begin -@interface BGMOutputDevicePrefs : NSObject +@interface BGMOutputDeviceMenuSection : NSObject - (instancetype) initWithBGMMenu:(NSMenu*)inBGMMenu audioDevices:(BGMAudioDeviceManager*)inAudioDevices diff --git a/BGMApp/BGMApp/BGMOutputDevicePrefs.mm b/BGMApp/BGMApp/BGMOutputDeviceMenuSection.mm similarity index 94% rename from BGMApp/BGMApp/BGMOutputDevicePrefs.mm rename to BGMApp/BGMApp/BGMOutputDeviceMenuSection.mm index 5ff73ad..f92eca3 100644 --- a/BGMApp/BGMApp/BGMOutputDevicePrefs.mm +++ b/BGMApp/BGMApp/BGMOutputDeviceMenuSection.mm @@ -14,14 +14,14 @@ // along with Background Music. If not, see . // -// BGMOutputDevicePrefs.mm +// BGMOutputDeviceMenuSection.mm // BGMApp // // Copyright © 2016-2018 Kyle Neideck // // Self Include -#import "BGMOutputDevicePrefs.h" +#import "BGMOutputDeviceMenuSection.h" // Local Includes #import "BGM_Utils.h" @@ -42,7 +42,7 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; -@implementation BGMOutputDevicePrefs { +@implementation BGMOutputDeviceMenuSection { NSMenu* bgmMenu; BGMAudioDeviceManager* audioDevices; BGMPreferredOutputDevices* preferredDevices; @@ -105,7 +105,7 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; - (void) listenForDevicesAddedOrRemoved { // Create the block that will run when a device is added or removed. - BGMOutputDevicePrefs* __weak weakSelf = self; + BGMOutputDeviceMenuSection* __weak weakSelf = self; refreshNeededListener = ^(UInt32 inNumberAddresses, const AudioObjectPropertyAddress* inAddresses) { @@ -128,11 +128,12 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; - (void) populateBGMMenu { // TODO: Technically, we should assert we're on the main queue rather than just the main thread. BGMAssert([NSThread isMainThread], - "BGMOutputDevicePrefs::populateBGMMenu called on non-main thread"); + "BGMOutputDeviceMenuSection::populateBGMMenu called on non-main thread"); // Remove existing menu items for (NSMenuItem* item in outputDeviceMenuItems) { - DebugMsg("BGMOutputDevicePrefs::populateBGMMenu: Removing %s", item.description.UTF8String); + DebugMsg("BGMOutputDeviceMenuSection::populateBGMMenu: Removing %s", + item.description.UTF8String); [bgmMenu removeItem:item]; } @@ -163,7 +164,7 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; if (canBeOutputDevice) { for (NSMenuItem* item : [self createMenuItemsForDevice:device]) { - DebugMsg("BGMOutputDevicePrefs::insertMenuItemsForDevice: Inserting %s", + DebugMsg("BGMOutputDeviceMenuSection::insertMenuItemsForDevice: Inserting %s", item.description.UTF8String); [bgmMenu insertItem:item atIndex:menuItemsIdx]; [outputDeviceMenuItems addObject:item]; @@ -224,7 +225,8 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; device.GetAvailableDataSources(scope, channel, numDataSources, dataSourceIDs); for (UInt32 i = 0; i < numDataSources; i++) { - DebugMsg("BGMOutputDevicePrefs::createMenuItemsForDevice: Creating item. %s%u %s%u", + DebugMsg("BGMOutputDeviceMenuSection::createMenuItemsForDevice: " + "Creating item. %s%u %s%u", "Device ID:", device.GetObjectID(), ", Data source ID:", dataSourceIDs[i]); @@ -240,7 +242,7 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; }); } } else { - DebugMsg("BGMOutputDevicePrefs::createMenuItemsForDevice: Creating item. %s%u", + DebugMsg("BGMOutputDeviceMenuSection::createMenuItemsForDevice: Creating item. %s%u", "Device ID:", device.GetObjectID()); BGM_Utils::LogAndSwallowExceptions(BGMDbgArgs, [&] { @@ -303,7 +305,7 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; // Called by BGMAudioDeviceManager to tell us a different device has been set as the output device. - (void) outputDeviceDidChange { - BGMOutputDevicePrefs* __weak weakSelf = self; + BGMOutputDeviceMenuSection* __weak weakSelf = self; dispatch_async(dispatch_get_main_queue(), ^{ BGM_Utils::LogAndSwallowExceptions(BGMDbgArgs, [&] { @@ -313,7 +315,7 @@ static NSInteger const kOutputDeviceMenuItemTag = 5; } - (void) outputDeviceMenuItemSelected:(NSMenuItem*)menuItem { - DebugMsg("BGMOutputDevicePrefs::outputDeviceMenuItemSelected: '%s' menu item selected", + DebugMsg("BGMOutputDeviceMenuSection::outputDeviceMenuItemSelected: '%s' menu item selected", [menuItem.title UTF8String]); // Make sure the menu item is actually for an output device. diff --git a/BGMApp/BGMAppTests/UITests/BGMAppUITests.mm b/BGMApp/BGMAppTests/UITests/BGMAppUITests.mm index 4a5a4ea..8037a7a 100644 --- a/BGMApp/BGMAppTests/UITests/BGMAppUITests.mm +++ b/BGMApp/BGMAppTests/UITests/BGMAppUITests.mm @@ -117,7 +117,7 @@ [icon click]; // Get the list of output devices from the main menu. - // BGMOutputDevicePrefs::createMenuItemForDevice gives every output device menu item the + // BGMOutputDeviceMenuSection::createMenuItemForDevice gives every output device menu item the // accessibility identifier "output-device" so we can find all of them here. NSArray* outputDeviceMenuItems = [menuItems matchingIdentifier:@"output-device"].allElementsBoundByIndex;