-
Notifications
You must be signed in to change notification settings - Fork 685
App Volumes Fixes
When an app plays audio, the OS gives a bundle ID, for example com.apple.WebKit.WebContent
, to Background Music's virtual audio driver (BGMDriver), but that bundle ID doesn't always match the bundle ID of the app itself, which could be com.apple.Safari
in this case. So when you use the volume slider for Safari, Background Music doesn't realise it should be controling the audio from com.apple.WebKit.WebContent
because the bundle ID for Safari is com.apple.Safari
.
There are a number of good ways to improve the situation, but no one has gotten around to implementing them yet. So for now we just have a list in the code with apps' bundle IDs and the bundle IDs those apps use when they play audio. That list is in the code here: https://github.com/kyleneideck/BackgroundMusic/blob/dfad77dc35cd065390cff0d870ed6bcb81042d7e/BGMApp/BGMApp/BGMBackgroundMusicDevice.cpp#L204
Adding an app to the list is tedious, but should be straightforward, even if you're not a programmer. Follow Installing from Source Code first so you know you'll be able to test your changes.
Then edit BGMApp/BGMApp/BGMBackgroundMusicDevice.cpp
and make a copy of one of the existing entries in the list, e.g.
// Safari
{ "com.apple.Safari", { "com.apple.WebKit.WebContent" } },
Change the app name in the copy (after //
), then you'll need to change the first bundle ID to the one for the app and the second bundle ID to the one that the Background Music virtual audio driver has for its audio.
Finding those bundle IDs can be a pain because you have to get debug logs from Background Music and find the bundle IDs in the logs. If you've already installed from source code, you can use /bin/bash build_and_install.sh -d
to install a debug build. Also note that "Option 1" in Getting Debug Logs won't work because you need logs from the driver as well.
For the app's bundle ID, move the volume slider and look for a line like
BGMAppVolumes::appVolumeChanged: App volume for com.apple.Safari (1509) changed to 49
Then for the other bundle ID, make the app play some audio (but not a sound effect like a notification bell) and look for a line like
BGM_Clients::StartIO: Client 167 (com.apple.WebKit.WebContent, 37328) starting IO
After you've added the app to the list, run /bin/bash build_and_install.sh
again to see if it worked. If it did, you can make a pull request to get it added for everyone. If you don't know how to do that, open an issue and paste the lines you added into it.