Commit graph

198 commits

Author SHA1 Message Date
Kyle Neideck
ec81520379
Fix BGMApp unit tests not compiling. 2017-10-29 01:00:37 +11:00
Kyle Neideck
1171bee102
Refactor non-UI code out of BGMAppVolumes. 2017-10-28 18:13:08 +11:00
Kyle Neideck
fb0740c4c1
Enable new compiler warnings suggested by Xcode. 2017-10-23 21:40:30 +11:00
Kyle Neideck
db63ae0cf1
Add BGMTermination files forgotten in previous commit. 2017-10-23 21:35:49 +11:00
Kyle Neideck
59e70fb9d1
Set the OS default audio device back if BGMApp exits abnormally.
This is mostly so BGMApp won't leave BGMDevice as the default if BGMApp
crashes, which would stop audio from playing until the user changed the
default device themselves. Also handles SIGINT, SIGTERM and SIGQUIT.

For crashes where the BGMApp process may be in an unknown state, e.g.
segfaults, BGMXPCHelper handles changing the default device.

Should fix the Travis Xcode 9 build, which is currently failing because
the AppleScript we use to quit BGMApp in .travis.yml gets "user
cancelled" for some reason.

Also makes some minor improvements to the reports generated by
CrashReporter. The way CrashReporter works with Background Music should
otherwise be unchanged.
2017-10-23 20:19:42 +11:00
Kyle Neideck
47ff99303a
Fix compiler warnings in Xcode 9.
Mostly -Wpartial-availability. Fixes #129.
2017-10-12 22:20:28 +11:00
Kyle Neideck
cce8111251
Add an App Volumes submenu for apps that aren't shown in the dock.
Specifically, apps with NSApplicationActivationPolicyAccessory. That
includes status bar apps like Background Music, but also includes some
that aren't intended to be shown to users as applications like
SystemUIServer.

I'm not sure how much we can do about that. It would probably help if we
hid apps that BGMDriver isn't able to match to a CoreAudio client.

Resolves #122.
2017-09-25 13:05:00 +10:00
Kyle Neideck
df67e4fa2b
Accessibility improvements for the volumes menu items. 2017-09-18 15:21:32 +10:00
Kyle Neideck
e4b98e4099
Add a UI test for the output volume slider. 2017-09-17 16:43:51 +10:00
Kyle Neideck
9fd5c89b27
Move the code for the output volume slider into a new class. 2017-09-16 22:09:03 +10:00
Kyle Neideck
3c001066c4
Set the output volume slider to 0 when the output device is muted. 2017-09-14 00:06:24 +10:00
Kyle Neideck
289f6b3d27
Fix a crash in BGMBackgroundMusicDevice::ResponsibleBundleIDsOf.
If the bundle ID passed to the function (a CACFString) was wrapping a
null CFStringRef, one of the comparison operator functions of CACFString
would pass null to CFStringCompare.
2017-09-12 20:09:04 +10:00
Kyle Neideck
07a419fb34
Add an output volume slider above the app volume sliders.
Similar to the one in macOS's Volume menu extra.

I'm mainly adding it so we can increase the output volume when the user
sets an app volume above 50%. Currently, setting an app volume above 50%
(the default) risks clipping, so it doesn't make sense to do so unless
your main output volume is at its max.

The volume slider added in this commit will make it clear to the user
that their main output volume is also increasing.

The other app volumes won't change, so in the ideal case the user
wouldn't need to be aware that their output device's volume is being
changed. But they might play audio to the device directly and would
expect it to play at the same volume as before they changed the app
volume.
2017-09-12 19:48:42 +10:00
Kyle Neideck
283db29fb4
App Volumes: Fix the hardcoded HAL client process bundle IDs.
Fix the workaround for apps whose bundle IDs don't match their CoreAudio
clients. BGMBackgroundMusicDevice::ResponsibleBundleIDsOf was always
returning an empty list.

Also fix over-releasing the app's bundle ID CFString in
BGMAVM_VolumeSlider::appVolumeChanged and
BGMAVM_PanSlider::appPanPositionChanged.

Both bugs were introduced two commits ago in
e05acde351.
2017-08-06 22:47:57 +10:00
Kyle Neideck
02558cd275
BGMApp: Move some more code into BGMBackgroundMusicDevice.
Mostly code for getting and setting BGMDevice's custom properties. Also
adds some stricter checking for property data received from BGMDevice.
2017-08-06 22:16:17 +10:00
Kyle Neideck
e05acde351
BGMApp: Move functions for talking to BGMDevice into their own class.
There's still some code left that should be moved into the new class,
BGMBackgroundMusicDevice, but I think this is most of it.

This also helps reduce/contain the code that has to be aware of the
second instance of BGMDevice, which handles UI-related audio.
2017-08-05 21:15:10 +10:00
Kyle Neideck
09aacabefa
Support Finder's Quicklook in App Volumes
Resolves #124.
2017-08-01 21:51:29 +10:00
Kyle Neideck
b715212cab
Ignore UI sounds when auto-pausing.
On macOS, apps are supposed to play UI-related sounds using the "system
default" device. This commit creates a new instance of BGM_Driver, which
BGMApp sets as the system default device. BGMApp ignores audio played to
that device when deciding whether to pause/unpause the user's music
player.

Since UI sounds are short, this helps avoid pausing the music player and
unpausing it shortly after.
2017-07-30 18:16:25 +10:00
Kyle Neideck
ccac7d7001
Rename BGMDevice from "Background Music Device" to "Background Music".
Resolves #116.
2017-06-25 12:39:34 +10:00
Kyle Neideck
243c798ccd
Disable AddressSanitizer in release builds. 2017-06-24 22:28:11 +10:00
Kyle Neideck
9aec1aed34
Enable AddressSanitizer by default in debug builds and tests.
Except when running BGMDriver because you have to change coreaudiod's
sandbox profile for that. And you have to disable SIP (rootless) to do
that.
2017-06-24 20:20:16 +10:00
Kyle Neideck
7f784b5d94
Add client bundle ID for Parallels to App Volumes.
Fixes #86.
2017-06-23 00:49:27 +10:00
Kyle Neideck
c907f13554
Partial fix for apps' bundle IDs not matching their HAL clients.
Some apps have different bundle IDs to their CoreAudio clients, so
the bundle ID BGMApp sends with the app's volume doesn't match any
client in BGMDriver.

This change hardcodes the bundle IDs used by some popular apps and the
bundle IDs their clients use. We should be able to fix this for all
(almost all?) apps at some point.
2017-06-22 19:36:17 +10:00
Kyle Neideck
5a657a01a6
Fix dropped frames when starting IO.
It turns out that the HAL will sometimes call BGM_Driver::StartIO before
sending kAudioDevicePropertyDeviceIsRunning to BGMPlayThrough. In that
case, BGMApp would start playthrough and tell BGMDriver to return from
StartIO immediately, which meant we would drop the initial frames while
the output device started up.

So now BGMApp waits for the output device in that case as well.

Fixes #7.
2017-06-22 19:36:17 +10:00
Kyle Neideck
aa8d9ae518
Increment minor version number. 2017-06-22 19:36:17 +10:00
Kyle Neideck
6d2fd39296
Split uninstall.sh into an interactive and non-interactive version.
The non-interactive version can be called by a Homebrew Cask formula.

Also, change some AppleScript to reference applications by their IDs
rather than their names, which should make them slightly more robust.
2017-06-17 21:56:42 +10:00
Kyle Neideck
3732eceed8
Increase the version number. (But just the patch level.) 2017-06-17 18:01:09 +10:00
Kyle Neideck
5e4556b49d
Add packaging script and (possibly) support for OS X 10.9. 2017-06-11 19:19:31 +10:00
Kyle Neideck
ec7128495f
Skip setting NSMenuItem.accessibilityTitle on OS X < 10.12.
This should also fix compilation with the 10.11 SDK.

Also enabled -Wpartial-availability and raised the deployment target to
OS X 10.9.
2017-06-03 23:17:34 +10:00
Kyle Neideck
b986b687ea
Fix exception in Mock_CAHALAudioObject during BGMApp unit tests.
Also, avoid initialising BGMDeviceControlsList in
BGMMockAudioDeviceManager::init.
2017-06-01 20:10:35 +10:00
Kyle Neideck
c617d98f9d
BGMDevice: Only enable volume/mute if the output device also has them.
BGMApp now disables BGMDevice's volume and/or mute controls if the
output device selected in BGMApp doesn't have matching controls. This
prevents the controls from being presented to the user when they don't
do anything.

In BGMPlayThrough, wait much longer for our IOProcs to stop themselves
before assuming something's gone wrong. In testing, rapidly changing
between output devices with and without controls while playing audio
would occasionally cause one of the IOProcs to take too long to stop
itself.

Also adds some basic scriptability, mainly so UI tests can use
AppleScript to check BGMApp's state that would be complicated to check
otherwise. (In this case, to check which output device is selected.)

Fixes #101.
2017-05-30 23:22:48 +10:00
Kyle Neideck
612e249e1b
Fix BGMApp crash when BGMDriver isn't installed. 2017-05-07 16:02:50 +10:00
Kyle Neideck
6a26afe47a
Fix nullability warning in BGMXPCHelper. Also add Xcode 8.3 to .travis.yml.
Fixes #107.
2017-04-05 22:15:54 +10:00
Kyle Neideck
78e2813af1
Fix encoding issue on Travis caused by "©" char in Python script. 2017-02-19 20:50:11 +11:00
Kyle Neideck
87af15d290
Skip the UI tests on Travis by directly editing BGMApp's Xcode scheme.
Skipping them by overriding runTest didn't work and this is the only other way
I can think of. xcodebuild's -skip-testing option would work, but only with
recent versions of Xcode.
2017-02-19 20:25:54 +11:00
Kyle Neideck
7b32b6ef66
Skip the UI tests on Travis because it doesn't support UI testing. 2017-02-19 17:43:45 +11:00
Kyle Neideck
32723ff04b
Append the git HEAD short ID to the build version for snapshot builds. 2017-02-19 15:14:34 +11:00
Kyle Neideck
60e1b3564b
Add a UI tests target for BGMApp. Only has one test so far.
The UI tests run with clean user defaults, but BGMDevice and Scripting Bridge
still need to be mocked/stubbed out. That also means that the UI tests can only
run if BGMDriver is installed and that changes to BGMDriver's state made during
the tests will persist.
2017-02-19 13:39:34 +11:00
Kyle Neideck
9b5d5bf921
Remove BGMAppTests, which was essentially empty. 2017-02-18 18:59:32 +11:00
Kyle Neideck
07c1c2320b
Reorganise the BGMApp test dirs slightly. 2017-02-18 18:12:40 +11:00
Kyle Neideck
8257f49b46
Merge pull request #98 from rakslice/pan 2017-02-14 23:32:21 +11:00
Kyle Neideck
cdea147010
Move the pan sliders into an "extra controls" section of the menu items.
Also add centre tick marks and "L"/"R" (left/right) labels to them.

The idea is to eventually include extra controls like an equalizer, recording
apps, hiding/ignoring apps, routing apps, etc.

Also, remove the left margin from the App Volumes menu items. Even macOS isn't
consistent about including that margin, as far as I can tell.
2017-02-11 16:47:52 +11:00
Kyle Neideck
a91615fc5e
Fix a deadlock when changing output device while IO is running.
BGM_Device::StartIO blocks on
BGMAudioDeviceManager::waitForOutputDeviceToStart, which could be blocked by
HAL requests that the HAL wouldn't return until BGM_Device::StartIO returned.

Also:
 - Replace BGMPlayThrough's move constructor with a SetDevices function for
   simplicity.
 - Pause/abort debug builds if an error is logged.
2017-02-01 09:09:00 +11:00
Kyle Neideck
467b072a9d
Don't throw in BGMPlayThrough::DestroyIOProcIDs if the device has been removed.
Also, default to only aborting debug builds when they log and swallow an
exception if the exception was unexpected. That is, the developer didn't
realise the code could throw.
2017-01-27 00:33:34 +11:00
Kyle Neideck
a62fae6fd1
Merge branch 'pan' of https://github.com/rakslice/BackgroundMusic into rakslice-pan 2017-01-18 21:49:20 +11:00
Kyle Neideck
129c21a180
Add BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS preprocessor flag. Also, add...
an option to build_and_install.sh for passing extra options to xcodebuild.
2017-01-16 23:58:19 +11:00
Kyle Neideck
2d135838fa
Add more error handling and logging to BGMPlayThrough. 2017-01-16 23:54:09 +11:00
Andrew Tonner
acf3976b9b remove suprious setCellClass call; cleanup 2017-01-09 14:58:05 -08:00
rakslice
61ce9ef165 better custom slider hack 2017-01-02 04:21:56 -08:00
rakslice
94c594b342 added per-app pan sliders 2017-01-02 02:30:00 -08:00
Kyle Neideck
2cb572ecf4
Revert "Fix default icon shown for BGMApp bundle."
This reverts commit a4160d370d.

I've tested the icon bug on a couple of other machines now and haven't been
able to reproduce it. My "fix" did cause the bug on those machines, though,
despite fixing it on mine. Still not sure exactly what's going on, but it seems
to be a problem with my development environment.
2016-12-31 21:05:04 +11:00
Kyle Neideck
8d5ea9c67c
Auto-pause: make the unpause delay proportional to the pause duration.
We only unpause the music player, after auto-pausing it, if it's been
paused for longer than some minimum length of time. This commit reduces
that time if the music player hasn't been paused for long.
2016-12-29 02:25:44 +11:00
Kyle Neideck
a4160d370d
Fix default icon shown for BGMApp bundle.
I'm not sure why this is necessary or why it works. Probably an Xcode
bug or something. This is with Xcode 8.2.1 on macOS 10.12.3 Beta
(16D17a).
2016-12-26 21:46:30 +11:00
Kyle Neideck
847313a174
Log debug messages to syslog and include debug symbols in BGMApp bundle.
In BGMApp, messages logged with the DebugMsg macro now go to syslog
instead of stdout.

People running standalone BGMApp debug builds (i.e. not in Xcode) should
be able the find the debug logs more easily. Xcode still shows the debug
logs normally when running BGMApp in Xcode.

Also, debug symbols (the .dSYM directory) are now included in the
Background Music.app bundle. (In both debug and release builds.)
CrashReporter is able to find these and use them to symbolicate BGMApp
crash logs.
2016-12-26 21:27:41 +11:00
Kyle Neideck
7992a5708c
Use data source names instead of device names in the output device menu.
The names of the data source(s) for a device are generally the names
intended to be shown to the user, since the OS X volume menu, System
Preferences, etc. use them.

A menu item is now added for each data source of each output device,
rather than one per device.

Also adds some macros/functions for casting values to __nonnull.

Resolves #59.
2016-12-23 01:46:27 +11:00
Kyle Neideck
31b501e832
Make BGMPlayThrough::WaitForOutputDeviceToStart noexcept. 2016-12-16 21:54:08 +11:00
Kyle Neideck
ab9d4cdc2b
Add more exception handling to BGMApp...
And other reliability improvements. Mostly in BGMPlayThrough and the
classes that use it. Trying to catch C++ exceptions as early as possible
in the Objective-C++ code and, if necessary, convert them to NSErrors.

More errors are logged in release builds now, which will hopefully help
with debugging issues the developers can't reproduce themselves.
2016-12-15 03:20:07 +11:00
Kyle Neideck
e0acb34f29 Assume non-null in BGMDeviceControlSync.cpp. 2016-11-14 22:13:46 +11:00
Kyle Neideck
ec87adb6e9 Allow MainMenu.xib to open in Xcode 7. Mostly to fix the tests in 7. 2016-11-14 21:58:23 +11:00
Kyle Neideck
810b2ed462 Fix BGMApp unit tests. 2016-11-13 01:32:26 +11:00
Kyle Neideck
c8f6790274 Add a link to the about panel and refactor its code.
Link to the project website (GitHub) in the About Background Music
window, and move its code into its own class.

Also, update the copyright notices in the UI and README.
2016-11-13 00:06:58 +11:00
Kyle Neideck
b0bfebedc4 Add Hermes music player. (A Pandora client.)
Closes #83.
2016-11-12 20:54:04 +11:00
Kyle Neideck
b2a12b3e37 Change "Vox" to "VOX" in filenames.
Fixes #77: build fails on case-sensitive filesystems.
2016-10-05 22:07:58 +11:00
Kyle Neideck
d38ea256cd Don't quit BGMApp if BGMXPCHelper is missing. See #76. 2016-09-26 11:08:19 +10:00
Kyle Neideck
e31f2b1c29 Refactor and clean up BGMApp's music player code and add tests. Also...
- Destroy the Scripting Bridge application object for a music player
  when that music player isn't running.
- Move the UI code for the auto-pause menu item into its own class.
- Add a User Defaults class to BGMApp.
- Enable some more warnings for the BGMApp project.
2016-09-17 18:24:19 +10:00
Kyle Neideck
59aa04c9bc Use dot notation for properties in BGMAppVolumes.mm 2016-09-11 15:33:23 +10:00
Kyle Neideck
cbbd48dcee Show Finder in the app volumes menu. Fixes #45. 2016-09-08 00:25:03 +10:00
Kyle Neideck
23fd57713d Fix nullability warnings in builds using the macOS 10.12 SDK.
Fixes #70.
2016-08-22 00:42:55 +10:00
Kyle Neideck
679d624860 Add BGM_Driver tests: get/set the music player bundle ID property. 2016-07-04 16:32:59 +10:00
Kyle Neideck
e3fcbdb37e Add BGMDecibel files to the Xcode project. 2016-06-30 09:30:05 +10:00
Kyle Neideck
3684483543 Merge branch 'Decibel' of https://github.com/hoke-t/BackgroundMusic into hoke-t-Decibel 2016-05-14 10:42:50 +10:00
Tanner Hoke
30a1735346 git rm extraneous Decibel files and use HTTPS links in README.md 2016-05-12 17:24:55 -05:00
Kyle Neideck
4dba9412fb Install NullAudio driver before tests run on Travis. 2016-05-11 10:02:31 +10:00
Kyle Neideck
bbe65a2431 Only pretend to disable the auto-pause menu item.
Instead of disabling the menu item when the music player isn't running,
just make it appear disabled. That way you can always disable auto-pause
without having to open your music player, but the UI still indicates
when it thinks the music player isn't running.
2016-05-11 00:08:46 +10:00
Kyle Neideck
a229791ade Merge branch 'master' of https://github.com/hoke-t/BackgroundMusic into hoke-t-master 2016-05-10 07:06:57 +10:00
Kyle Neideck
b58ad2a1f8 Fix possible deadlock when starting IO.
BGM_Device::StartIO was holding the state mutex longer than it needed
to, which meant HasProperty, GetProperty, etc. couldn't return. If
BGMPlayThrough was notified about IO starting after StartIO locked the
mutex, BGMPlayThrough would get stuck trying to get one of BGMDevice's
properties.

Fixes #46.
2016-04-30 21:28:16 +10:00
Kyle Neideck
960fe0d28d Fix rare race condition in BGM_TaskQueue (hopefully).
Also enable a few more warnings in the BGMDriver project.
2016-04-30 20:50:29 +10:00
Kyle Neideck
7f136586dc Add versions of launchctl commands for OS X 10.9 and 10.10.
The launchctl commands in our scripts should now all work on any version
of OS X from 10.9. But I haven't actually tested that.

Fixes #35.
2016-04-21 01:48:14 +10:00
Tanner Hoke
7cc0d19182 Put music files in the correct group. 2016-04-19 10:43:24 -05:00
Tanner Hoke
5981e05bb1 Add support for Decibel 2016-04-18 21:37:29 -05:00
Tanner Hoke
e87c43dc52 Disable the Auto-pause Music menu item if the selected music player isn't running 2016-04-18 20:15:28 -05:00
Kyle Neideck
f1c57fe4e9 Disable optimization profile in BGMApp. (Hopefully temporary.)
BGMApp is failing to build for some people with the Clang error message
"Could not read profile: Unsupported profiling format version". See #4.

I think this might be caused by building with an older version of Xcode,
but I'm far from sure about that. BGMApp uses <0.5% CPU, so it's not
worth using an optimization profile if it's causing anyone problems.
2016-04-18 04:36:24 +10:00
Tom
171ed1bec1 added parenthesis to print function call for python 3 compatability 2016-04-17 17:53:09 +01:00
Kyle Neideck
6b0ca53304 Forgot to add VOX music player to the README.
Also, capitalized "VOX".
2016-04-18 00:53:46 +10:00
Kyle Neideck
6d0fde1780 Add the Vox music player to BGMApp.
Resolves #2.
2016-04-18 00:36:55 +10:00
Kyle Neideck
267c5a38e7 Fix unused variable warnings when building with the release config.
These were stopping BGMApp release builds from compiling because we have
warnings-as-errors enabled.
2016-04-10 17:08:30 +10:00
Kyle Neideck
f8fe456f44 Fix BGMApp causing VLC to open. 2016-04-09 10:05:43 +10:00
Kyle Neideck
6ea4361135 Add Xcode schemes. 2016-04-08 05:12:11 +10:00
Kyle Neideck
f12e9c60df Fix deadlock when changing output device while audio is playing.
Also fixes a semaphore leak in BGMPlayThrough.
2016-04-08 02:33:30 +10:00
Kyle Neideck
f3151e3159 BGMXPCHelper now runs as an unprivileged user, instead of root.
BGMXPCHelper's install script now creates a user and group for
BGMXPCHelper to run as. This reduces the risk of BGMXPCHelper being used
for privilege escalation.
2016-04-07 00:48:36 +10:00
Kyle Neideck
690d6221d7 Add script that builds and installs BGMApp, BGMDriver and BGMXPCHelper 2016-04-05 16:56:38 +10:00
Kyle Neideck
1672bb8ed0 BGMXPCHelper can now be installed with xcodebuild.
The "install" action for BGMXPCHelper now checks the owner/permissions
of the installation directory. It also installs BGMXPCHelper's
launchd.plist and "bootstraps" it.
2016-04-04 04:55:17 +10:00
Kyle Neideck
33b6b17115 Add an XPC helper. Sync BGMApp and BGMDriver with it while starting IO.
The BGMApp project now builds an XPC service bundle called BGMXPCHelper,
which vends a Mach service that BGMApp and BGMDriver can use to
communicate. This will hopefully be useful for some of the tasks HAL
notifications aren't suited to.

In this commit, BGMDriver uses the XPC helper when starting IO, to wait
until BGMApp is ready for playthrough. BGMApp can only start playthrough
when the output hardware is ready for IO. BGMDriver can now tell the HAL
when we're ready for IO, which means we don't have to keep the output
hardware running all the time (or drop frames or increase latency).

The end result is that playthrough doesn't waste CPU time while idle any
more. This also means that now playthrough won't prevent the system from
sleeping when idle.
2016-03-31 11:42:24 +11:00
Kyle Neideck
d378ab5d44 Add VLC as a music player in BGMApp
Also moved the music player Scripting Bridge files.
2016-02-24 18:21:13 +11:00
Kyle Neideck
646c00ceb6 Sync BGMDevice volume with output device correctly on BGMApp startup
The listener proc in BGMDeviceControlSync was being triggered during the
initial CopyVolume call. This fix just waits until after the initial
sync to register the listener proc.
2016-02-23 18:57:47 +11:00
Kyle Neideck
5336a5a670 Add notes about testing with Address Sanitizer 2016-02-20 19:04:19 +11:00
Kyle Neideck
199f5f6a6b Prefer list initialization for in-class initialized member objects 2016-02-20 17:21:05 +11:00
Kyle Neideck
b17d736382 Initial commit 2016-02-19 16:25:34 +11:00