Permalink
Please sign in to comment.
Showing
with
30,137 additions
and 0 deletions.
- +30 −0 .gitignore
- +25 −0 BGM.xcworkspace/contents.xcworkspacedata
- +808 −0 BGMApp/BGMApp.xcodeproj/project.pbxproj
- +37 −0 BGMApp/BGMApp/AppDelegate.h
- +144 −0 BGMApp/BGMApp/AppDelegate.mm
- +57 −0 BGMApp/BGMApp/BGMAppVolumes.h
- +298 −0 BGMApp/BGMApp/BGMAppVolumes.mm
- +53 −0 BGMApp/BGMApp/BGMAudioDeviceManager.h
- +215 −0 BGMApp/BGMApp/BGMAudioDeviceManager.mm
- +40 −0 BGMApp/BGMApp/BGMAutoPauseMusic.h
- +187 −0 BGMApp/BGMApp/BGMAutoPauseMusic.mm
- +355 −0 BGMApp/BGMApp/BGMDeviceControlSync.cpp
- +81 −0 BGMApp/BGMApp/BGMDeviceControlSync.h
- +662 −0 BGMApp/BGMApp/BGMPlayThrough.cpp
- +140 −0 BGMApp/BGMApp/BGMPlayThrough.h
- +197 −0 BGMApp/BGMApp/Base.lproj/MainMenu.xib
- +68 −0 BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/Contents.json
- BIN BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/appicon_1024.png
- BIN BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/appicon_128.png
- BIN BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/appicon_16.png
- BIN BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/appicon_256.png
- BIN BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/appicon_32.png
- BIN BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/appicon_512.png
- BIN BGMApp/BGMApp/Images.xcassets/AppIcon.appiconset/appicon_64.png
- +6 −0 BGMApp/BGMApp/Images.xcassets/Contents.json
- +12 −0 BGMApp/BGMApp/Images.xcassets/FermataIcon.imageset/Contents.json
- BIN BGMApp/BGMApp/Images.xcassets/FermataIcon.imageset/FermataIcon.pdf
- +38 −0 BGMApp/BGMApp/Info.plist
- +339 −0 BGMApp/BGMApp/LICENSE
- +106 −0 BGMApp/BGMApp/Music Players/BGMMusicPlayer.h
- +67 −0 BGMApp/BGMApp/Music Players/BGMMusicPlayer.m
- +30 −0 BGMApp/BGMApp/Music Players/BGMSpotify.h
- +101 −0 BGMApp/BGMApp/Music Players/BGMSpotify.m
- +31 −0 BGMApp/BGMApp/Music Players/BGMiTunes.h
- +103 −0 BGMApp/BGMApp/Music Players/BGMiTunes.m
- +40 −0 BGMApp/BGMApp/Preferences/BGMAutoPauseMusicPrefs.h
- +205 −0 BGMApp/BGMApp/Preferences/BGMAutoPauseMusicPrefs.mm
- +36 −0 BGMApp/BGMApp/Preferences/BGMOutputDevicePrefs.h
- +107 −0 BGMApp/BGMApp/Preferences/BGMOutputDevicePrefs.mm
- +45 −0 BGMApp/BGMApp/Preferences/BGMPreferencesMenu.h
- +131 −0 BGMApp/BGMApp/Preferences/BGMPreferencesMenu.mm
- +82 −0 BGMApp/BGMApp/Spotify.h
- +528 −0 BGMApp/BGMApp/iTunes.h
- +29 −0 BGMApp/BGMApp/main.m
- +58 −0 BGMApp/BGMAppTests/BGMAppTests.m
- +24 −0 BGMApp/BGMAppTests/Info.plist
- BIN BGMApp/OptimizationProfiles/BGMApp.profdata
- +305 −0 BGMApp/PublicUtility/CAAtomic.h
- +508 −0 BGMApp/PublicUtility/CAAutoDisposer.h
- +206 −0 BGMApp/PublicUtility/CABitOperations.h
- +821 −0 BGMApp/PublicUtility/CACFArray.cpp
- +195 −0 BGMApp/PublicUtility/CACFArray.h
- +581 −0 BGMApp/PublicUtility/CACFDictionary.cpp
- +176 −0 BGMApp/PublicUtility/CACFDictionary.h
- +83 −0 BGMApp/PublicUtility/CACFNumber.cpp
- +151 −0 BGMApp/PublicUtility/CACFNumber.h
- +110 −0 BGMApp/PublicUtility/CACFString.cpp
- +196 −0 BGMApp/PublicUtility/CACFString.h
- +90 −0 BGMApp/PublicUtility/CADebugMacros.cpp
- +581 −0 BGMApp/PublicUtility/CADebugMacros.h
- +89 −0 BGMApp/PublicUtility/CADebugPrintf.cpp
- +115 −0 BGMApp/PublicUtility/CADebugPrintf.h
- +103 −0 BGMApp/PublicUtility/CADebugger.cpp
- +69 −0 BGMApp/PublicUtility/CADebugger.h
- +83 −0 BGMApp/PublicUtility/CAException.h
- +1,156 −0 BGMApp/PublicUtility/CAHALAudioDevice.cpp
- +238 −0 BGMApp/PublicUtility/CAHALAudioDevice.h
- +370 −0 BGMApp/PublicUtility/CAHALAudioObject.cpp
- +155 −0 BGMApp/PublicUtility/CAHALAudioObject.h
- +182 −0 BGMApp/PublicUtility/CAHALAudioStream.cpp
- +94 −0 BGMApp/PublicUtility/CAHALAudioStream.h
- +181 −0 BGMApp/PublicUtility/CAHALAudioSystemObject.cpp
- +90 −0 BGMApp/PublicUtility/CAHALAudioSystemObject.h
- +99 −0 BGMApp/PublicUtility/CAHostTimeBase.cpp
- +234 −0 BGMApp/PublicUtility/CAHostTimeBase.h
- +345 −0 BGMApp/PublicUtility/CAMutex.cpp
- +163 −0 BGMApp/PublicUtility/CAMutex.h
- +450 −0 BGMApp/PublicUtility/CAPThread.cpp
- +191 −0 BGMApp/PublicUtility/CAPThread.h
- +312 −0 BGMApp/PublicUtility/CAPropertyAddress.h
- +319 −0 BGMApp/PublicUtility/CARingBuffer.cpp
- +126 −0 BGMApp/PublicUtility/CARingBuffer.h
- +678 −0 BGMDriver/BGMDriver.xcodeproj/project.pbxproj
- +2,342 −0 BGMDriver/BGMDriver/BGM_Device.cpp
- +224 −0 BGMDriver/BGMDriver/BGM_Device.h
- +188 −0 BGMDriver/BGMDriver/BGM_Object.cpp
- +162 −0 BGMDriver/BGMDriver/BGM_Object.h
- +220 −0 BGMDriver/BGMDriver/BGM_PlugIn.cpp
- +87 −0 BGMDriver/BGMDriver/BGM_PlugIn.h
- +812 −0 BGMDriver/BGMDriver/BGM_PlugInInterface.cpp
- +461 −0 BGMDriver/BGMDriver/BGM_TaskQueue.cpp
- +196 −0 BGMDriver/BGMDriver/BGM_TaskQueue.h
- +162 −0 BGMDriver/BGMDriver/BGM_Types.h
- +45 −0 BGMDriver/BGMDriver/BGM_WrappedAudioEngine.cpp
- +48 −0 BGMDriver/BGMDriver/BGM_WrappedAudioEngine.h
- +52 −0 BGMDriver/BGMDriver/DeviceClients/BGM_Client.cpp
- +80 −0 BGMDriver/BGMDriver/DeviceClients/BGM_Client.h
- +359 −0 BGMDriver/BGMDriver/DeviceClients/BGM_ClientMap.cpp
- +174 −0 BGMDriver/BGMDriver/DeviceClients/BGM_ClientMap.h
- +56 −0 BGMDriver/BGMDriver/DeviceClients/BGM_ClientTasks.h
- +359 −0 BGMDriver/BGMDriver/DeviceClients/BGM_Clients.cpp
- +142 −0 BGMDriver/BGMDriver/DeviceClients/BGM_Clients.h
- BIN BGMDriver/BGMDriver/DeviceIcon.icns
- +38 −0 BGMDriver/BGMDriver/Info.plist
- +211 −0 BGMDriver/BGMDriver/quick_install.sh
- +224 −0 BGMDriver/BGMDriverTests/BGM_ClientMapTests.mm
- +130 −0 BGMDriver/BGMDriverTests/BGM_ClientsTests.mm
- +55 −0 BGMDriver/BGMDriverTests/BGM_DeviceTests.mm
- +46 −0 BGMDriver/BGMDriverTests/BGM_TestUtils.h
- +24 −0 BGMDriver/BGMDriverTests/Info.plist
- +305 −0 BGMDriver/PublicUtility/CAAtomic.h
- +239 −0 BGMDriver/PublicUtility/CAAtomicStack.h
- +508 −0 BGMDriver/PublicUtility/CAAutoDisposer.h
- +821 −0 BGMDriver/PublicUtility/CACFArray.cpp
- +195 −0 BGMDriver/PublicUtility/CACFArray.h
- +581 −0 BGMDriver/PublicUtility/CACFDictionary.cpp
- +176 −0 BGMDriver/PublicUtility/CACFDictionary.h
- +83 −0 BGMDriver/PublicUtility/CACFNumber.cpp
- +151 −0 BGMDriver/PublicUtility/CACFNumber.h
- +110 −0 BGMDriver/PublicUtility/CACFString.cpp
- +180 −0 BGMDriver/PublicUtility/CACFString.h
- +90 −0 BGMDriver/PublicUtility/CADebugMacros.cpp
- +581 −0 BGMDriver/PublicUtility/CADebugMacros.h
- +89 −0 BGMDriver/PublicUtility/CADebugPrintf.cpp
- +115 −0 BGMDriver/PublicUtility/CADebugPrintf.h
- +103 −0 BGMDriver/PublicUtility/CADebugger.cpp
- +69 −0 BGMDriver/PublicUtility/CADebugger.h
- +438 −0 BGMDriver/PublicUtility/CADispatchQueue.cpp
- +235 −0 BGMDriver/PublicUtility/CADispatchQueue.h
- +83 −0 BGMDriver/PublicUtility/CAException.h
- +99 −0 BGMDriver/PublicUtility/CAHostTimeBase.cpp
- +234 −0 BGMDriver/PublicUtility/CAHostTimeBase.h
- +345 −0 BGMDriver/PublicUtility/CAMutex.cpp
- +164 −0 BGMDriver/PublicUtility/CAMutex.h
- +450 −0 BGMDriver/PublicUtility/CAPThread.cpp
- +191 −0 BGMDriver/PublicUtility/CAPThread.h
- +482 −0 BGMDriver/PublicUtility/CAVolumeCurve.cpp
- +178 −0 BGMDriver/PublicUtility/CAVolumeCurve.h
- +22 −0 CONTRIBUTING.md
- +148 −0 DEVELOPING.md
- BIN Images/FermataIcon.pdf
- +63 −0 Images/FermataIcon.tex
- BIN Images/README/FermataIcon.png
- BIN Images/README/Screenshot.png
- +86 −0 Images/generate_icon_pngs.sh
- +38 −0 Images/iconizer.sh
- BIN LICENSE
- +129 −0 README.md
- +99 −0 TODO.md
30
.gitignore
| @@ -0,0 +1,30 @@ | ||
| +.DS_Store | ||
| +.*.swp | ||
| +/BGMDriver/BGMDriver/quick_install.conf | ||
| + | ||
| +# Everything below is from https://github.com/github/gitignore/blob/master/Objective-C.gitignore | ||
| + | ||
| +## Build generated | ||
| +build/ | ||
| +DerivedData | ||
| + | ||
| +## Various settings | ||
| +*.pbxuser | ||
| +!default.pbxuser | ||
| +*.mode1v3 | ||
| +!default.mode1v3 | ||
| +*.mode2v3 | ||
| +!default.mode2v3 | ||
| +*.perspectivev3 | ||
| +!default.perspectivev3 | ||
| +xcuserdata | ||
| + | ||
| +## Other | ||
| +*.xccheckout | ||
| +*.moved-aside | ||
| +*.xcuserstate | ||
| +*.xcscmblueprint | ||
| + | ||
| +## Obj-C/Swift specific | ||
| +*.hmap | ||
| +*.ipa |
| @@ -0,0 +1,37 @@ | ||
| +// This file is part of Background Music. | ||
| +// | ||
| +// Background Music is free software: you can redistribute it and/or | ||
| +// modify it under the terms of the GNU General Public License as | ||
| +// published by the Free Software Foundation, either version 2 of the | ||
| +// License, or (at your option) any later version. | ||
| +// | ||
| +// Background Music is distributed in the hope that it will be useful, | ||
| +// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| +// GNU General Public License for more details. | ||
| +// | ||
| +// You should have received a copy of the GNU General Public License | ||
| +// along with Background Music. If not, see <http://www.gnu.org/licenses/>. | ||
| + | ||
| +// | ||
| +// AppDelegate.h | ||
| +// BGMApp | ||
| +// | ||
| +// Copyright © 2016 Kyle Neideck | ||
| +// | ||
| +// Sets up and tears down the app. | ||
| +// | ||
| + | ||
| +#import <Cocoa/Cocoa.h> | ||
| + | ||
| + | ||
| +@interface AppDelegate : NSObject <NSApplicationDelegate> | ||
| + | ||
| +@property (weak) IBOutlet NSMenu* bgmMenu; | ||
| +@property (weak) IBOutlet NSMenuItem* autoPauseMenuItem; | ||
| +@property (weak) IBOutlet NSView* appVolumeView; | ||
| +@property (weak) IBOutlet NSPanel* aboutPanel; | ||
| +@property (unsafe_unretained) IBOutlet NSTextView *aboutPanelLicenseView; | ||
| + | ||
| +@end | ||
| + |
| @@ -0,0 +1,144 @@ | ||
| +// This file is part of Background Music. | ||
| +// | ||
| +// Background Music is free software: you can redistribute it and/or | ||
| +// modify it under the terms of the GNU General Public License as | ||
| +// published by the Free Software Foundation, either version 2 of the | ||
| +// License, or (at your option) any later version. | ||
| +// | ||
| +// Background Music is distributed in the hope that it will be useful, | ||
| +// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| +// GNU General Public License for more details. | ||
| +// | ||
| +// You should have received a copy of the GNU General Public License | ||
| +// along with Background Music. If not, see <http://www.gnu.org/licenses/>. | ||
| + | ||
| +// | ||
| +// AppDelegate.mm | ||
| +// BGMApp | ||
| +// | ||
| +// Copyright © 2016 Kyle Neideck | ||
| +// | ||
| + | ||
| +// Self Includes | ||
| +#import "AppDelegate.h" | ||
| + | ||
| +// Local Includes | ||
| +#include "BGM_Types.h" | ||
| +#import "BGMAudioDeviceManager.h" | ||
| +#import "BGMAutoPauseMusic.h" | ||
| +#import "BGMAppVolumes.h" | ||
| +#import "BGMPreferencesMenu.h" | ||
| + | ||
| + | ||
| +static float const kStatusBarIconPadding = 0.25; | ||
| + | ||
| +@implementation AppDelegate { | ||
| + // The button in the system status bar (the bar with volume, battery, clock, etc.) to show the main menu | ||
| + // for the app. These are called "menu bar extras" in the Human Interface Guidelines. | ||
| + NSStatusItem* statusBarItem; | ||
| + | ||
| + BGMAutoPauseMusic* autoPauseMusic; | ||
| + BGMAppVolumes* appVolumes; | ||
| + BGMAudioDeviceManager* audioDevices; | ||
| + BGMPreferencesMenu* prefsMenu; | ||
| +} | ||
| + | ||
| +- (void) awakeFromNib { | ||
| + // Set up the status bar item | ||
| + statusBarItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; | ||
| + | ||
| + // Set the icon | ||
| + NSImage* icon = [NSImage imageNamed:@"FermataIcon"]; | ||
| + if (icon != nil) { | ||
| + CGFloat lengthMinusPadding = [[statusBarItem button] frame].size.height * (1 - kStatusBarIconPadding); | ||
| + [icon setSize:NSMakeSize(lengthMinusPadding, lengthMinusPadding)]; | ||
| + // Make the icon a "template image" so it gets drawn colour-inverted when it's highlighted or the status | ||
| + // bar's in dark mode | ||
| + [icon setTemplate:YES]; | ||
| + statusBarItem.button.image = icon; | ||
| + } else { | ||
| + // If our icon is missing for some reason, fallback to a fermata character (1D110) | ||
| + statusBarItem.button.title = @"𝄐"; | ||
| + } | ||
| + | ||
| + // Set the main menu | ||
| + statusBarItem.menu = self.bgmMenu; | ||
| +} | ||
| + | ||
| +- (void) applicationDidFinishLaunching:(NSNotification*)aNotification { | ||
| + #pragma unused (aNotification) | ||
| + | ||
| + // Coordinates the audio devices (BGMDevice and the output device): manages playthrough, volume/mute controls, etc. | ||
| + NSError* err; | ||
| + audioDevices = [[BGMAudioDeviceManager alloc] initWithError:&err]; | ||
| + if (audioDevices == nil) { | ||
| + [self showDeviceNotFoundErrorMessageAndExit:err.code]; | ||
| + } | ||
| + [audioDevices setBGMDeviceAsOSDefault]; | ||
| + | ||
| + // Register the preference defaults. These are the preferences/state that only apply to BGMApp. The others are | ||
| + // persisted on BGMDriver. | ||
| + NSDictionary* appDefaults = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] | ||
| + forKey:@"AutoPauseMusicEnabled"]; | ||
| + [[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults]; | ||
| + | ||
| + autoPauseMusic = [[BGMAutoPauseMusic alloc] initWithAudioDevices:audioDevices]; | ||
| + | ||
| + // Enable auto-pausing music if it's enabled in the user's preferences (which it is by default) | ||
| + if ([[NSUserDefaults standardUserDefaults] boolForKey:@"AutoPauseMusicEnabled"]) { | ||
| + [self toggleAutoPauseMusic:self]; | ||
| + } | ||
| + | ||
| + appVolumes = [[BGMAppVolumes alloc] initWithMenu:[self bgmMenu] | ||
| + appVolumeView:[self appVolumeView] | ||
| + audioDevices:audioDevices]; | ||
| + | ||
| + prefsMenu = [[BGMPreferencesMenu alloc] initWithbgmMenu:[self bgmMenu] | ||
| + audioDevices:audioDevices | ||
| + aboutPanel:[self aboutPanel] | ||
| + aboutPanelLicenseView:[self aboutPanelLicenseView]]; | ||
| +} | ||
| + | ||
| +- (void) showDeviceNotFoundErrorMessageAndExit:(NSInteger)code { | ||
| + // Show an error dialog and exit if either BGMDevice wasn't found on the system or we couldn't find any output devices | ||
| + | ||
| + NSAlert* alert = [NSAlert new]; | ||
| + | ||
| + if (code == kBGMErrorCode_BGMDeviceNotFound) { | ||
| + // TODO: Check whether the driver files are in /Library/Audio/Plug-Ins/HAL and offer to install them if not. Also, | ||
| + // it would be nice if we could restart coreaudiod automatically (using launchd). | ||
| + [alert setMessageText:@"Could not find the Background Music virtual audio device."]; | ||
| + [alert setInformativeText:@"Make sure you've installed Background Music.driver to /Library/Audio/Plug-Ins/HAL and restarted coreaudiod (e.g. \"sudo killall coreaudiod\")."]; | ||
| + } else if(code == kBGMErrorCode_OutputDeviceNotFound) { | ||
| + [alert setMessageText:@"Could not find an audio output device."]; | ||
| + [alert setInformativeText:@"If you do have one installed, this is probably a bug. Sorry about that. Feel free to file an issue on GitHub."]; | ||
| + } | ||
| + | ||
| + [alert runModal]; | ||
| + [NSApp terminate:self]; | ||
| +} | ||
| + | ||
| +- (void) applicationWillTerminate:(NSNotification*)aNotification { | ||
| + #pragma unused (aNotification) | ||
| + [audioDevices unsetBGMDeviceAsOSDefault]; | ||
| +} | ||
| + | ||
| +- (IBAction) toggleAutoPauseMusic:(id)sender { | ||
| + #pragma unused (sender) | ||
| + | ||
| + if (self.autoPauseMenuItem.state == NSOnState) { | ||
| + self.autoPauseMenuItem.state = NSOffState; | ||
| + [autoPauseMusic disable]; | ||
| + } else { | ||
| + self.autoPauseMenuItem.state = NSOnState; | ||
| + [autoPauseMusic enable]; | ||
| + } | ||
| + | ||
| + // Persist the change in the user's preferences | ||
| + [[NSUserDefaults standardUserDefaults] setBool:(self.autoPauseMenuItem.state == NSOnState) | ||
| + forKey:@"AutoPauseMusicEnabled"]; | ||
| +} | ||
| + | ||
| +@end | ||
| + |
| @@ -0,0 +1,57 @@ | ||
| +// This file is part of Background Music. | ||
| +// | ||
| +// Background Music is free software: you can redistribute it and/or | ||
| +// modify it under the terms of the GNU General Public License as | ||
| +// published by the Free Software Foundation, either version 2 of the | ||
| +// License, or (at your option) any later version. | ||
| +// | ||
| +// Background Music is distributed in the hope that it will be useful, | ||
| +// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| +// GNU General Public License for more details. | ||
| +// | ||
| +// You should have received a copy of the GNU General Public License | ||
| +// along with Background Music. If not, see <http://www.gnu.org/licenses/>. | ||
| + | ||
| +// | ||
| +// BGMAppVolumes.h | ||
| +// BGMApp | ||
| +// | ||
| +// Copyright © 2016 Kyle Neideck | ||
| +// | ||
| + | ||
| +// Local Includes | ||
| +#import "BGMAudioDeviceManager.h" | ||
| + | ||
| +// System Includes | ||
| +#import <Cocoa/Cocoa.h> | ||
| + | ||
| + | ||
| +@interface BGMAppVolumes : NSObject | ||
| + | ||
| +- (id) initWithMenu:(NSMenu*)menu appVolumeView:(NSView*)view audioDevices:(BGMAudioDeviceManager*)audioDevices; | ||
| + | ||
| +@end | ||
| + | ||
| +// Protocol for the UI custom classes | ||
| + | ||
| +@protocol BGMAppVolumeSubview <NSObject> | ||
| + | ||
| +- (void) setUpWithApp:(NSRunningApplication*)app context:(BGMAppVolumes*)ctx; | ||
| + | ||
| +@end | ||
| + | ||
| +// Custom classes for the UI elements in the app volume menu items | ||
| + | ||
| +@interface BGMAVM_AppIcon : NSImageView <BGMAppVolumeSubview> | ||
| +@end | ||
| + | ||
| +@interface BGMAVM_AppNameLabel : NSTextField <BGMAppVolumeSubview> | ||
| +@end | ||
| + | ||
| +@interface BGMAVM_VolumeSlider : NSSlider <BGMAppVolumeSubview> | ||
| + | ||
| +- (void) setRelativeVolume:(NSNumber*)relativeVolume; | ||
| + | ||
| +@end | ||
| + |
Oops, something went wrong.
0 comments on commit
b17d736