This works similarly to the workaround in the previous commit, but
avoids the short wait while XPC times out. It still allows some initial
frames to be dropped when IO starts.
See #328, #388 and PR #390.
Add NSSupportsAutomaticGraphicsSwitching to BGMApp's Info.plist in the
hopes that it will use the integrated GPU when possible. BGMApp doesn't
need to use the fastest GPU, so it's better to save battery power.
Untested because I don't have the right hardware. (I actually have an
iMac with a discrete GPU, but the integrated GPU seems to be disabled.)
See #284 and
<https://developer.apple.com/library/archive/qa/qa1734/_index.html>.
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.)
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.
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.
It was using the copy in the BGMApp project, but for historical reasons
they both have a separate copy of the PublicUtility classes. We haven't
gotten around to combining them yet, so this commit is to keep them
consistent until we do.
Also, some minor clean up in BGMDriver related to #218.
The install and uninstall scripts try to restart coreaudiod in a number
of ways until one works. Despite that, it still wasn't always successful
when I tested it on macOS Catalina. This commit will hopefully fix that.
`sudo` is usually passwordless in Travis CI builds, but for some reason
`sudo -v` still causes a password prompt in macOS Travis builds.
_uninstall-non-interactive.sh already included a workaround for this,
but it doesn't work when the Travis build for the Homebrew Cask calls
`brew uninstall background-music`, which then calls
_uninstall-non-interactive.sh. The old workaround used the `TRAVIS` env
var, but Homebrew seems to run the script in an environment without it.
See <https://github.com/Homebrew/homebrew-cask/pull/67524>.
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.)
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.
Fixes the same issue as df9815a4be, but in
BGMOutputVolumeMenuItem instead of BGMStatusBarItem.
I think the problem was that it captured a weak reference in a C++
lambda, but it would capture by (C++) reference and when the reference
was used it would be referencing invalid memory. The fix to have the
lambda capture by value instead.
See #202.
I think that, because BGMStatusBarItem::initWithMenu was capturing a
weak reference in a C++ lambda as a C++ reference, the C++ reference
would be invalid when it was used. The fix to have the lambda capture by
value instead.
I'm not completely sure why builds from Xcode never crashed or why ASan
didn't catch the bug. Maybe the stack memory was just never
reused/invalidated with Xcode builds. (And I probably just don't
understand how ASan works well enough.)
Fixes#202.
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.
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.
BGMApp has to set BGMDevice, and often also the Null Device for a short
time, as the systemwide default audio device, which makes CoreAudio put
them in the preferred devices list in its Plist file. And since the list
is limited to three devices, it only gives us one or two usable ones.
Ideally, CoreAudio just wouldn't add our devices to its list, but I
don't think we can prevent that.
As a partial workaround, we now store our own copy of the preferred
devices list without our devices, which BGMApp can use to figure out
which devices were pushed out of CoreAudio's list by our devices.
This doesn't fix the problem entirely because our devices still take up
room in CoreAudio's list when BGMApp is closed, but I think that would
be harder to solve.
See #167.
Also:
- Handle setting the initial output device in BGMPreferredOutputDevices
instead of BGMAudioDeviceManager.
- Fix a crash in BGMOutputVolumeMenuItem::dealloc caused by using
dispatch_sync to dispatch to the main queue while running on the main
queue.
- Fix a crash in BGMPreferredOutputDevices if
/Library/Preferences/Audio/com.apple.audio.SystemSettings.plist
doesn't exist.
- Add Swinsian to the list of music players in the README. (I must have
forgotten to do that when I added support for it.)
When the user chooses a different output device in BGMApp, the new
device is now added to the front of the list of preferred devices. This
stops BGMPreferredOutputDevices changing the output device back shortly
afterward when it gets a device connection/disconnection notification,
which is sent because BGMDriver's Null Device is enabled and then
disabled as part of changing the output device.
It also means BGMApp will now account for the times the output device
has been changed since BGMApp started when deciding whether to change to
a newly connected device and deciding which device to change to when the
current output device is 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.
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.
For the label above the output device volume slider, we use the name of
the output device's current data source, if it has one. But it was only
being updated when the user changed to a different output device.
BGMOutputVolumeMenuItem now updates the label if the output device
changes to a different data source, e.g. from Internal Speakers to
Headphones.
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.
Users reporting bugs will be able to use these packages to install debug
builds of Background Music without having to install from source. This
is mainly useful because debug builds have more detailed logging.
Hopefully we'll get around to adding an option to enable debug logging
at runtime, but this should work well enough for now.
Also:
- Use newer macOS images in Travis CI builds.
- Fix an xcrun command in build_and_install.sh that was accidentally
being started in the background.
- Fix build_and_install.sh building libPublicUtility.a twice for no
reason.
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).
FaceTime plays call audio using a daemon called avconferenced, so
BGMDriver can't tell where the audio is actually coming from. As a
hopefully temporary fix, BGMApp now just sets avconferenced's volume to
match FaceTime's. See #139.
Also,
- set a tooltip and accessibility label for BGMApp's status bar item
(the thing you click to show the main menu), and
- some minor refactoring.