App Volume Control lets you control the individual volume levels of Android apps [Root]
...so you can play games while quietly listening to music
If you’ve ever tried to play audio from several Android apps simultaneously on your smartphone, you’ve probably realized that it sucks to do this. It would be nice to casually enjoy an Android game while your favorite music from Spotify is blasting in the background. On the other hand, it would also be nice if you could mostly focus on the gameplay in a game like Call of Duty: Mobile without having your music completely overtaking the game audio. The problem with Android is that the OS only offers a few audio streams that you can control the volume of, one of which is the media stream. This media stream is where games and most music apps have to output their audio, so in most cases you’re stuck controlling the volume of both games and music simultaneously. Fortunately, there’s a new mod for rooted phones called “App Volume Control” that seeks to solve this.
Android offers the concept of “audio focus“, a set of APIs that can cooperatively be utilized by third-party apps so that only one app can hold the focus at a time. Apps can choose whether or not their audio should halt or “duck” whenever another app takes over the audio focus. Because Google left it up to developers to decide how to handle things when the audio focus is lost, there’s a lot of inconsistency in how apps behave when another app takes over audio focus.
XDA Junior Member Alcatraz323 came up with an interesting open-source mod that not only allows you to force concurrent audio to be played by multiple apps (in case one app chooses to halt its music when another app takes over the audio focus) but also has the ability to control volumes on a per-app basis. The developer released a companion app called “App Volume Control” on the Google Play Store, and they also released a Magisk Module called “Audio HeadQuarter” to set up the mod. The Magisk Module consists of low-level libraries while the Android app allows you to customize volume behavior on a per-app basis. Users can create and tune app-specific audio presets through the companion app after a successful installation of the module. Users can also enable the app’s floating window to easily tune the volumes outside of the app.
According to the developer, close-to-stock software or AOSP-derived custom ROMs like LineageOS are the most compatible with this mod. Heavy OEM skins such as Xiaomi’s MIUI or Huawei’s EMUI might have issues getting the mod to work. We installed this mod on our rooted Google Pixel 4 running Android 10 to verify it works. We were able to get it to recognize when Spotify is playing, which allowed us to control the loudness of the music from Spotify while we were playing Call of Duty: Mobile. The app was unable to recognize music playback from Google Play Music, though. The app warns that it may not recognize direct audio output sessions that aren’t sent through the AudioMixer API, which this mod hooks into. Thus, your mileage may vary.
The source code of the app and module are hosted on GitHub. You can download the Audio HeadQuarter module using the search function in Magisk Manager, or you can grab it directly from the GitHub release page of the repository. The developer recommends not to use Canary builds of Magisk and suggests installing the mod on top of Magisk 20.2 or later. While you can install the companion app (linked below) from the Google Play Store, the app alone can’t do anything without the underlying binaries.
Note: The module’s default installation option is to set SELinux to permissive, which is highly insecure and not recommended to do. The developer notes that a newer version of the module, which hasn’t been published on GitHub yet, may work with SELinux set to enforcing.