diff --git a/BGMDriver/BGMDriver/BGM_Device.cpp b/BGMDriver/BGMDriver/BGM_Device.cpp index c26a200..37953e6 100644 --- a/BGMDriver/BGMDriver/BGM_Device.cpp +++ b/BGMDriver/BGMDriver/BGM_Device.cpp @@ -20,8 +20,8 @@ // Copyright © 2016 Kyle Neideck // Portions copyright (C) 2013 Apple Inc. All Rights Reserved. // -// Based largely on SA_Device.cpp from Apple's SimpleAudioPlugin sample code. Also uses a few sections from Apple's NullAudio.c -// sample code (found in the same sample project). +// Based largely on SA_Device.cpp from Apple's SimpleAudioDriver Plug-In sample code. Also uses a few sections from Apple's +// NullAudio.c sample code (found in the same sample project). // https://developer.apple.com/library/mac/samplecode/AudioDriverExamples // @@ -1828,7 +1828,7 @@ void BGM_Device::StartIO(UInt32 inClientID) // An overview of the process this function is part of: // - A client starts IO. - // - The plugin host (the HAL) calls the StartIO function in BGM_PluginInterface, which calls this function. + // - The plugin host (the HAL) calls the StartIO function in BGM_PlugInInterface, which calls this function. // - BGMDriver sends a message to BGMApp telling it to start the (real) audio hardware. // - BGMApp starts the hardware and, after the hardware is ready, replies to BGMDriver's message. // - BGMDriver lets the host know that it's ready to do IO by returning from StartIO. diff --git a/BGMDriver/BGMDriver/BGM_Device.h b/BGMDriver/BGMDriver/BGM_Device.h index 6a4e575..8b7b0b9 100644 --- a/BGMDriver/BGMDriver/BGM_Device.h +++ b/BGMDriver/BGMDriver/BGM_Device.h @@ -20,7 +20,7 @@ // Copyright © 2016 Kyle Neideck // Portions copyright (C) 2013 Apple Inc. All Rights Reserved. // -// Based largely on SA_Device.h from Apple's SimpleAudioPlugin sample code. +// Based largely on SA_Device.h from Apple's SimpleAudioDriver Plug-In sample code. // https://developer.apple.com/library/mac/samplecode/AudioDriverExamples // diff --git a/BGMDriver/BGMDriver/BGM_Object.cpp b/BGMDriver/BGMDriver/BGM_Object.cpp index 965b259..e680067 100644 --- a/BGMDriver/BGMDriver/BGM_Object.cpp +++ b/BGMDriver/BGMDriver/BGM_Object.cpp @@ -20,7 +20,7 @@ // Copyright © 2016 Kyle Neideck // Portions copyright (C) 2013 Apple Inc. All Rights Reserved. // -// Based largely on SA_Object.cpp from Apple's SimpleAudioPlugin sample code. +// Based largely on SA_Object.cpp from Apple's SimpleAudioDriver Plug-In sample code. // https://developer.apple.com/library/mac/samplecode/AudioDriverExamples // // Similarly to BGM_Object.h, this file hasn't been changed much from SA_Object.cpp, except to diff --git a/BGMDriver/BGMDriver/BGM_Object.h b/BGMDriver/BGMDriver/BGM_Object.h index b510195..ba3ce4a 100644 --- a/BGMDriver/BGMDriver/BGM_Object.h +++ b/BGMDriver/BGMDriver/BGM_Object.h @@ -20,10 +20,10 @@ // Copyright © 2016 Kyle Neideck // Portions copyright (C) 2013 Apple Inc. All Rights Reserved. // -// Based largely on SA_Object.h from Apple's SimpleAudioPlugin sample code. +// Based largely on SA_Object.h from Apple's SimpleAudioDriver Plug-In sample code. // https://developer.apple.com/library/mac/samplecode/AudioDriverExamples // -// The base class for our classes that represent audio objects. (See AudioServerPlugin.h for a +// The base class for our classes that represent audio objects. (See AudioServerPlugIn.h for a // quick explanation of audio objects.) // // This is a stripped down version of SA_Object.h. Unlike the sample code plugin that SA_Object.h diff --git a/BGMDriver/BGMDriver/BGM_PlugIn.cpp b/BGMDriver/BGMDriver/BGM_PlugIn.cpp index 571e705..55d2819 100644 --- a/BGMDriver/BGMDriver/BGM_PlugIn.cpp +++ b/BGMDriver/BGMDriver/BGM_PlugIn.cpp @@ -20,7 +20,7 @@ // Copyright © 2016 Kyle Neideck // Portions copyright (C) 2013 Apple Inc. All Rights Reserved. // -// Based largely on SA_PlugIn.cpp from Apple's SimpleAudioPlugin sample code. +// Based largely on SA_PlugIn.cpp from Apple's SimpleAudioDriver Plug-In sample code. // https://developer.apple.com/library/mac/samplecode/AudioDriverExamples // diff --git a/BGMDriver/BGMDriver/BGM_PlugIn.h b/BGMDriver/BGMDriver/BGM_PlugIn.h index f537592..6537f6d 100644 --- a/BGMDriver/BGMDriver/BGM_PlugIn.h +++ b/BGMDriver/BGMDriver/BGM_PlugIn.h @@ -20,7 +20,7 @@ // Copyright © 2016 Kyle Neideck // Portions copyright (C) 2013 Apple Inc. All Rights Reserved. // -// Based largely on SA_PlugIn.h from Apple's SimpleAudioPlugin sample code. +// Based largely on SA_PlugIn.h from Apple's SimpleAudioDriver Plug-In sample code. // https://developer.apple.com/library/mac/samplecode/AudioDriverExamples // diff --git a/BGMDriver/BGMDriver/BGM_PlugInInterface.cpp b/BGMDriver/BGMDriver/BGM_PlugInInterface.cpp index 5e01fd9..5228053 100644 --- a/BGMDriver/BGMDriver/BGM_PlugInInterface.cpp +++ b/BGMDriver/BGMDriver/BGM_PlugInInterface.cpp @@ -20,7 +20,7 @@ // Copyright © 2016 Kyle Neideck // Portions copyright (C) 2013 Apple Inc. All Rights Reserved. // -// Based largely on SA_PlugIn.cpp from Apple's SimpleAudioPlugin sample code. +// Based largely on SA_PlugIn.cpp from Apple's SimpleAudioDriver Plug-In sample code. // https://developer.apple.com/library/mac/samplecode/AudioDriverExamples // diff --git a/SharedSource/BGM_Types.h b/SharedSource/BGM_Types.h index 32cb363..7f05729 100644 --- a/SharedSource/BGM_Types.h +++ b/SharedSource/BGM_Types.h @@ -23,7 +23,7 @@ #ifndef __SharedSource__BGM_Types__ #define __SharedSource__BGM_Types__ -#include +#include #pragma mark IDs @@ -36,9 +36,9 @@ #define kBGMDeviceUID "BGMDevice" #define kBGMDeviceModelUID "BGMDeviceModelUID" -// The object IDs for the audio objects this driver implements +// The object IDs for the audio objects this driver implements. // -// Regardless of the wrapped device, this driver always publishes this fixed set of objects. We might need to +// BGMDevice always publishes this fixed set of objects (regardless of the wrapped device). We might need to // change that at some point, but so far it hasn't caused any problems and it makes the driver much simpler. enum { @@ -50,7 +50,7 @@ enum kObjectID_Mute_Output_Master = 6 }; -#pragma mark Custom properties +#pragma mark BGMDevice Custom Properties enum { @@ -116,31 +116,9 @@ enum #define kAppRelativeVolumeMinDbValue -96.0f #define kAppRelativeVolumeMaxDbValue 0.0f -#pragma mark XPC Return Codes +#pragma mark BGMDevice Custom Property Addresses -enum { - kBGMXPC_Success, - kBGMXPC_MessageFailure, - kBGMXPC_Timeout, - kBGMXPC_BGMAppStateError, - kBGMXPC_HardwareError, - kBGMXPC_InternalError -}; - -#pragma mark Exceptions - -#if defined(__cplusplus) - -class BGM_InvalidClientException { }; -class BGM_InvalidClientPIDException { }; -class BGM_InvalidClientRelativeVolumeException { }; -class BGM_DeviceNotSetException { }; - -#endif - -#pragma mark Property Addresses - -// For convenience +// For convenience. static const AudioObjectPropertyAddress kBGMMusicPlayerProcessIDAddress = { kAudioDeviceCustomPropertyMusicPlayerProcessID, @@ -172,5 +150,27 @@ static const AudioObjectPropertyAddress kBGMAppVolumesAddress = { kAudioObjectPropertyElementMaster }; +#pragma mark XPC Return Codes + +enum { + kBGMXPC_Success, + kBGMXPC_MessageFailure, + kBGMXPC_Timeout, + kBGMXPC_BGMAppStateError, + kBGMXPC_HardwareError, + kBGMXPC_InternalError +}; + +#pragma mark Exceptions + +#if defined(__cplusplus) + +class BGM_InvalidClientException { }; +class BGM_InvalidClientPIDException { }; +class BGM_InvalidClientRelativeVolumeException { }; +class BGM_DeviceNotSetException { }; + +#endif + #endif /* __SharedSource__BGM_Types__ */ diff --git a/TODO.md b/TODO.md index dbcc634..0e4ed50 100644 --- a/TODO.md +++ b/TODO.md @@ -85,9 +85,13 @@ There are also lots of other TODOs commented around the code. - When BGMApp changes the default device to BGMDevice, some apps seem to keep using the previous default device if they were running IO at the time. Not sure if we can do anything about this. -- Figure out how to test BGMDriver with Address Sanitizer enabled. It isn't working because coreaudiod will try to read - files outside of its sandbox. +- Figure out how to test BGMDriver with Address Sanitizer enabled. It isn't working because it makes coreaudiod try to + read files outside of its sandbox and the system kills it. - Crash reporting +- Test Background Music on a system running OS X on a case-sensitive file system. In + [#64](https://github.com/kyleneideck/BackgroundMusic/issues/64), BGMDriver failed to compile and the error suggests it + was a case-sensitivity problem. That should be fixed now, but I haven't looked for any runtime bugs. + diff --git a/build_and_install.sh b/build_and_install.sh index 9930d95..784236f 100755 --- a/build_and_install.sh +++ b/build_and_install.sh @@ -468,9 +468,14 @@ echo "[3/3] Installing $(bold_face ${APP_DIR}) to $(bold_face ${APP_PATH})." \ show_spinner "${BUILD_FAILED_ERROR_MSG}" # Fix Background Music.app owner/group. -# (We have to run xcodebuild as root to install BGMXPCHelper because it installs to directories +# +# We have to run xcodebuild as root to install BGMXPCHelper because it installs to directories # owned by root. But that means the build directory gets created by root, and since BGMApp uses the -# same build directory we have to run xcodebuild as root to install BGMApp as well.) +# same build directory we have to run xcodebuild as root to install BGMApp as well. +# +# TODO: Can't we just chown -R the build dir before we install BGMApp? Then we wouldn't have to +# install BGMApp as root. (But maybe still handle the unlikely case of APP_PATH not being +# user-writable.) sudo chown -R "$(whoami):admin" "${APP_PATH}/${APP_DIR}" # Fix the build directories' owner/group. This is mainly so the whole source directory can be diff --git a/uninstall.sh b/uninstall.sh index e631566..170958f 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -148,6 +148,7 @@ if [ "$user_prompt" == "y" ] || [ "$user_prompt" == "Y" ]; then # Invalidate sudo ticket sudo -k + # TODO: What if they only have one audio device? echo -e "\n${bold}Done! Toggle your sound output device in the Sound control panel to complete the uninstall.${normal}" osascript -e 'tell application "System Preferences"