Skip to content

Commit

Permalink
Rename BGMOutputDevicePrefs to BGMOutputDeviceMenuSection.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleneideck committed Nov 4, 2018
1 parent 5e12f9f commit 7b8d1a0
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 37 deletions.
16 changes: 8 additions & 8 deletions BGMApp/BGMApp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -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 */; };
Expand Down Expand Up @@ -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 = "<group>"; };
1CD410D31F9EDDAD0070A094 /* BGMAppVolumesController.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = BGMAppVolumesController.mm; sourceTree = "<group>"; };
1CE7064A1BF1EC0600BFC06D /* BGMOutputDevicePrefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BGMOutputDevicePrefs.h; sourceTree = "<group>"; };
1CE7064B1BF1EC0600BFC06D /* BGMOutputDevicePrefs.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BGMOutputDevicePrefs.mm; sourceTree = "<group>"; };
1CE7064A1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BGMOutputDeviceMenuSection.h; sourceTree = "<group>"; };
1CE7064B1BF1EC0600BFC06D /* BGMOutputDeviceMenuSection.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BGMOutputDeviceMenuSection.mm; sourceTree = "<group>"; };
1CEACF4E1F34A30000FEC143 /* Mock_CAHALAudioSystemObject.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Mock_CAHALAudioSystemObject.cpp; path = UnitTests/Mock_CAHALAudioSystemObject.cpp; sourceTree = "<group>"; };
1CED61681C3081C2002CAFCF /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
1CED616A1C316E1A002CAFCF /* BGMAudioDeviceManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BGMAudioDeviceManager.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down
13 changes: 7 additions & 6 deletions BGMApp/BGMApp/BGMAppDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -62,7 +62,7 @@ @implementation BGMAppDelegate {
BGMMusicPlayers* musicPlayers;
BGMSystemSoundsVolume* systemSoundsVolume;
BGMAppVolumesController* appVolumes;
BGMOutputDevicePrefs* outputDevicePrefs;
BGMOutputDeviceMenuSection* outputDeviceMenuSection;
BGMPreferencesMenu* prefsMenu;
BGMXPCListener* xpcListener;
BGMPreferredOutputDevices* preferredOutputDevices;
Expand Down Expand Up @@ -295,10 +295,11 @@ - (void) setUpMainMenu:(BGMUserDefaults*)userDefaults {
[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
Expand Down
6 changes: 3 additions & 3 deletions BGMApp/BGMApp/BGMAudioDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

// Forward Declarations
@class BGMOutputVolumeMenuItem;
@class BGMOutputDevicePrefs;
@class BGMOutputDeviceMenuSection;


#pragma clang assume_nonnull begin
Expand All @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions BGMApp/BGMApp/BGMAudioDeviceManager.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -61,7 +61,7 @@ @implementation BGMAudioDeviceManager {
NSXPCConnection* __nullable bgmXPCHelperConnection;

BGMOutputVolumeMenuItem* __nullable outputVolumeMenuItem;
BGMOutputDevicePrefs* __nullable outputDevicePrefs;
BGMOutputDeviceMenuSection* __nullable outputDeviceMenuSection;

NSRecursiveLock* stateLock;
}
Expand All @@ -73,7 +73,7 @@ - (instancetype) init {
stateLock = [NSRecursiveLock new];
bgmXPCHelperConnection = nil;
outputVolumeMenuItem = nil;
outputDevicePrefs = nil;
outputDeviceMenuSection = nil;
outputDevice = kAudioObjectUnknown;

try {
Expand Down Expand Up @@ -105,8 +105,8 @@ - (void) setOutputVolumeMenuItem:(BGMOutputVolumeMenuItem*)item {
outputVolumeMenuItem = item;
}

- (void) setOutputDevicePrefs:(BGMOutputDevicePrefs*)prefs {
outputDevicePrefs = prefs;
- (void) setOutputDeviceMenuSection:(BGMOutputDeviceMenuSection*)menuSection {
outputDeviceMenuSection = menuSection;
}

#pragma mark Systemwide Default Device
Expand Down Expand Up @@ -331,7 +331,7 @@ - (void) propagateOutputDeviceChange {

// Update the menu item for the volume of the output device.
[outputVolumeMenuItem outputDeviceDidChange];
[outputDevicePrefs outputDeviceDidChange];
[outputDeviceMenuSection outputDeviceDidChange];
}

- (NSError*) failedToSetOutputDevice:(AudioDeviceID)deviceID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// along with Background Music. If not, see <http://www.gnu.org/licenses/>.

//
// BGMOutputDevicePrefs.h
// BGMOutputDeviceMenuSection.h
// BGMApp
//
// Copyright © 2016, 2018 Kyle Neideck
Expand All @@ -30,7 +30,7 @@

#pragma clang assume_nonnull begin

@interface BGMOutputDevicePrefs : NSObject
@interface BGMOutputDeviceMenuSection : NSObject

- (instancetype) initWithBGMMenu:(NSMenu*)inBGMMenu
audioDevices:(BGMAudioDeviceManager*)inAudioDevices
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
// along with Background Music. If not, see <http://www.gnu.org/licenses/>.

//
// BGMOutputDevicePrefs.mm
// BGMOutputDeviceMenuSection.mm
// BGMApp
//
// Copyright © 2016-2018 Kyle Neideck
//

// Self Include
#import "BGMOutputDevicePrefs.h"
#import "BGMOutputDeviceMenuSection.h"

// Local Includes
#import "BGM_Utils.h"
Expand All @@ -42,7 +42,7 @@

static NSInteger const kOutputDeviceMenuItemTag = 5;

@implementation BGMOutputDevicePrefs {
@implementation BGMOutputDeviceMenuSection {
NSMenu* bgmMenu;
BGMAudioDeviceManager* audioDevices;
BGMPreferredOutputDevices* preferredDevices;
Expand Down Expand Up @@ -105,7 +105,7 @@ - (void) dealloc {

- (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) {
Expand All @@ -128,11 +128,12 @@ - (void) listenForDevicesAddedOrRemoved {
- (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];
}

Expand Down Expand Up @@ -163,7 +164,7 @@ - (void) insertMenuItemsForDevice:(BGMAudioDevice)device {

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];
Expand Down Expand Up @@ -224,7 +225,8 @@ - (void) insertMenuItemsForDevice:(BGMAudioDevice)device {
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]);

Expand All @@ -240,7 +242,7 @@ - (void) insertMenuItemsForDevice:(BGMAudioDevice)device {
});
}
} else {
DebugMsg("BGMOutputDevicePrefs::createMenuItemsForDevice: Creating item. %s%u",
DebugMsg("BGMOutputDeviceMenuSection::createMenuItemsForDevice: Creating item. %s%u",
"Device ID:", device.GetObjectID());

BGM_Utils::LogAndSwallowExceptions(BGMDbgArgs, [&] {
Expand Down Expand Up @@ -303,7 +305,7 @@ - (NSMenuItem*) createMenuItemForDevice:(CAHALAudioDevice)device

// 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, [&] {
Expand All @@ -313,7 +315,7 @@ - (void) outputDeviceDidChange {
}

- (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.
Expand Down
2 changes: 1 addition & 1 deletion BGMApp/BGMAppTests/UITests/BGMAppUITests.mm
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ - (void) testCycleOutputDevices {
[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<XCUIElement*>* outputDeviceMenuItems =
[menuItems matchingIdentifier:@"output-device"].allElementsBoundByIndex;
Expand Down

0 comments on commit 7b8d1a0

Please sign in to comment.