Clarify some comments in BGMPreferredOutputDevices.

This commit is contained in:
Kyle Neideck 2018-10-28 18:11:40 +11:00
parent 4c0c656538
commit 94f13e747c
No known key found for this signature in database
GPG key ID: CAA8D9B8E39EC18C
3 changed files with 12 additions and 9 deletions

View file

@ -48,9 +48,9 @@
- (instancetype) initWithDevices:(BGMAudioDeviceManager*)devices
userDefaults:(BGMUserDefaults*)userDefaults;
// Returns the most-preferred device currently connected. If no preferred devices are connected,
// returns the current output device. If the current output device has been disconnected, returns
// an arbitrary device.
// Returns the most-preferred device that's currently connected. If no preferred devices are
// connected, returns the current output device. If the current output device has been disconnected,
// returns an arbitrary device.
//
// If none of the connected devices can be used as the output device, or if it can't find a device
// to use because the HAL returned errors when queried, returns kAudioObjectUnknown.

View file

@ -110,15 +110,18 @@ NSString* const kAudioSystemSettingsPlist =
// Default to a list with just the systemwide default device (or an empty list if that fails) if
// we can't read the preferred devices from the Plist because preferredDeviceUIDsFrom will use
// BGMApp's stored preferred devices to fill in the rest.
// BGMApp's stored preferred devices to fill in the rest optimistically. This doesn't help us
// tell when to switch to a newly connected device, but it should improve our chances of
// switching to the best device if the current output device is disconnected.
NSArray<NSDictionary*>* preferredOutputDeviceInfos = @[];
// If we can't read the Plist, we only know that the current systemwide default device is the
// most-preferred device.
// most-preferred device that's currently connected.
//
// TODO: If we are able to read the Plist, check that the systemwide default device is the
// most-preferred in the list from the Plist. If it isn't, the format of the Plist has
// probably changed, so we should ignore it's data and log a warning.
// most-preferred device in the list from the Plist that's also connected. If it isn't,
// the format of the Plist has probably changed, so we should ignore its data and log a
// warning.
BGM_Utils::LogAndSwallowExceptions(BGMDbgArgs, [&] {
BGMAudioDevice defaultDevice = CAHALAudioSystemObject().GetDefaultAudioDevice(false, false);
NSString* __nullable defaultDeviceUID =
@ -294,7 +297,7 @@ NSString* const kAudioSystemSettingsPlist =
if (!defaultDevice.IsBGMDeviceInstance()) {
// BGMDevice isn't the systemwide default device, so we know the default device is the
// most preferred.
// most-preferred device that's currently connected.
preferredDevice = defaultDevice;
}
});

View file

@ -19,7 +19,7 @@
#
# build_and_install.sh
#
# Copyright © 2016, 2017 Kyle Neideck
# Copyright © 2016-2018 Kyle Neideck
# Copyright © 2016 Nick Jacques
#
# Builds and installs BGMApp, BGMDriver and BGMXPCHelper. Requires xcodebuild and Xcode.