Commit graph

67 commits

Author SHA1 Message Date
Antoine Cœur
f31aebcf51 spelling 2022-01-21 09:35:16 +08:00
Kyle Neideck
b38f6ddcd6
Reduce noise in the CI logs.
CI builds that use Xcode 12.2 are going over Travis CI's log length
limit and getting killed.
2021-03-31 14:31:08 +11:00
Marcus Wu
2090761ae5 Add BGMASApplication to test target 2021-03-19 21:00:39 -04:00
Marcus Wu
9765193c1f Added app volume and pan setting to AppleScript 2021-03-19 20:29:36 -04:00
Kyle Neideck
488ed16dfc
Hopefully fix a segfault caused by BGM_PlayThrough.
Issue #276 reported a segfault that occurred while BGMApp was launching.
It was caused by BGM_PlayThrough's output IOProc when it tried to read
from the ring buffer. I haven't been able to reproduce the problem, so I
don't know whether this commit will actually fix it. Hopefully it will
at least make it easier to diagnose.

This commit adds locking around accesses to the buffer so that the
IOProcs will skip the current IO cycle if it isn't safe to use the ring
buffer. That should only happen during launch or when changing the
output device. (And only if something else has gone wrong.)
2020-04-18 22:00:49 +10:00
Kyle Neideck
23ecf7e46e
Fix BGMDriver and BGMXPCHelper's version strings for SNAPSHOT builds.
And DEBUG builds. The "-SNAPSHOT-abc0123" suffix was only being added to
the version string for BGMApp.
2020-02-09 22:18:52 +11:00
Kyle Neideck
8de821d4aa
Add an archive option (-a) to build_and_install.sh.
Archiving is the standard way to build a release for distribution using
Xcode. package.sh now uses this option when it creates a release
package.

This change is mainly to keep the Run settings in the Xcode schemes from
affecting the release builds, which means we can commit the schemes with
more sensible settings.

Also, disable AddressSanitizer in the BGMDevice scheme, which was
stopping coreaudiod from launching because its sandbox won't allow the
process to load the AddressSanitizer dylib.
2020-02-05 00:09:14 +11:00
Kyle Neideck
2c1677305d
Add optional debug logging in release builds.
Clicking the status bar icon with the option key held now reveals a
setting that enables debug logging in BGMApp. It's enabled by default in
debug builds.

It doesn't enable debug logging in BGMDriver or BGMXPCHelper yet.

This will hopefully make it easier for people to include logs when they
report bugs that don't occur with most hardware or are otherwise hard to
reproduce.

Enabling debug logging should be unlikely to cause audio glitches, but I
haven't tried to make it completely safe.

Also,
 - add some basic unit tests for BGMPlayThrough and expand the mocks for
   the CoreAudio HAL API,
 - fix the UI tests so you can run them without code signing them, and
 - update copyright years.
2020-01-24 08:07:34 +11:00
Kyle Neideck
0a7be7d32c
Enable Hardened Runtime in BGMApp, BGMXPCHelper and BGMDriver.
This is required for Notarization, which will be mandatory in macOS
Catalina.

Also, suppress some STL deprecation warnings in PublicUtility code. (The
warnings were recently added to Clang.)
2019-08-05 21:25:57 +10:00
Kyle Neideck
94fc1259e3
Add BGMMusic files to the Xcode project.
Also, add BGMMusic to BGMMusicPlayers and add the Scripting Bridge
header for Music.app.

Resolves #216.
2019-07-03 02:34:15 +10:00
Kyle Neideck
04f17301a1
Fix BGMApp test compilation.
Updates the lists of files to be compiled when the tests are built,
which were missing the new source files added in the previous commit.
2019-06-09 19:43:17 +10:00
Kyle Neideck
e616718eab
Add music player: Google Play Music Desktop Player.
The code for GPMDP is a lot more complicated than the code for other
music players. See BGMGooglePlayMusicDesktopPlayer.h for details.

Adds a class, BGMAppWatcher, to hold the code that notifies listeners
when a given app is launched or terminated.

Resolves #161.
2019-06-09 18:56:12 +10:00
Kyle Neideck
e093e7d3b2
Add an option to use a volume icon instead of the Background Music logo.
This is so the icon can show the current volume. Then you can hide the
built-in volume status bar item in System Preferences.

Closes #183.
2019-03-05 00:01:42 +11:00
Kyle Neideck
a4c93c050b
Fix build_and_install.sh failing when run from a path containing spaces.
When build_and_install.sh tried to install BGMXPCHelper, xcodebuild
would fail to run post_install.sh.

Fixes #187.
2019-01-22 21:58:47 +11:00
Kyle Neideck
475d141ae4
Make builds more deterministic.
Packages built with package.sh should now be byte-identical except for
timestamps in Assets.car (in BGMApp resources) and modification dates in
the package's Bom file, if built with the same version of Xcode.
Hopefully this will be enough to allow builds to be reproduced, with a
bit of effort.
2018-11-12 19:15:26 +11:00
Kyle Neideck
7b8d1a0e0d
Rename BGMOutputDevicePrefs to BGMOutputDeviceMenuSection. 2018-11-04 15:28:01 +11:00
Kyle Neideck
5e12f9fc01
Move the output device menu items to the main menu.
I don't know why I put them in the Preferences menu initially. This is
more convenient.

Closes #170.

Also:
 - Update the output device menu items as needed instead of when the
   user opens the menu. This saves a bit of CPU time and means if the
   user has the menu open, changes are made when they're needed instead
   of the next time the user opens the menu.
 - Fix BGMAppUITests::testCycleOutputDevices for the latest Xcode/macOS.
2018-11-04 12:30:43 +11:00
Kyle Neideck
1bb3873a53
Change output device in some cases when devices are added/removed.
Tries to copy the way CoreAudio normally handles devices being added or
removed, which it can't do while Background Music is running (because
BGMDevice needs to be the default output device for the system).

This may break when Background Music is run on later versions of macOS
as the only way BGMApp can tell what CoreAudio (probably) would have
done is by reading one of its Plist files directly.

See #167.
2018-10-23 14:07:13 +11:00
Kyle Neideck
b0282706df
Fix adding "SNAPSHOT"/"DEBUG" to the version string with multiple tags.
The most recent tag is now used to decide whether to add "-SNAPSHOT-..."
to the version string. So now we can make a new release by tagging a
commit even if we've already made a snapshot/debug release from the same
commit.
2018-10-16 12:38:52 +11:00
Kyle Neideck
75e8d5ceac
Request user permission to use input devices and Apple Events.
This is required to build against the macOS 10.14 SDK because 10.14
requires users to grant apps permission before they can use audio input
devices or send Apple Events to other apps.

I think builds built against the 10.13 SDK were supposed to continue
working, but I haven't tested it.

Note that without NSMicrophoneUsageDescription and
NSAppleEventsUsageDescription, 10.14 builds will fail more or less
silently when they try to use those features. (tccd does log a message
about it, though.)

See #163.
2018-10-03 13:28:18 +10:00
Kyle Neideck
ed06a257a8
Add auto-pause support for Swinsian. See #141. 2018-02-25 12:01:43 +11:00
Kyle Neideck
3ba53a50ac
Support building snapshot releases by creating tags.
If HEAD is tagged, check for "SNAPSHOT" or "DEBUG" in the tag name when
generating the version string for a build. If found, add
"-SNAPSHOT-abcdef0" or "-DEBUG-abcdef0" at the end of the version
string (where "abcdef0" is the short commit ID for HEAD).
2018-02-24 17:55:29 +11:00
Kyle Neideck
f64cf41f8a
Add a volume slider for system sounds.
System sounds are UI-related sounds like mail notifications or terminal
bells.

Xcode 9.2 doesn't support saving .xib files in Xcode 7 format any more,
so building Background Music now requires Xcode 8 or above.

Also, fix some of the tooltips that would only work if BGMApp was the
foreground app, which it shouldn't be.
2017-12-26 23:10:57 +11:00
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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