I am writing an app to record the audio from the device, using REMOTE_SUBMIX. According to this PAGE, it is said that
Certain streams are excluded from the remote submix, including STREAM_RING, STREAM_ALARM, and STREAM_NOTIFICATION. These streams will continue to be presented locally as usual.
Now I want to exclude STREAM_SYSTEM also, but I cannot find where this policy/strategy is defined in the AOSP souce code or any configuration file.
Does anyone know any clue about it? Thanks a lot.
It's in the audiopolicy service code (unless you are on an Intel device which uses routing code based on Parameter Framework, then it's in a configuration file).
I think the code you are interested in is here:
https://android.googlesource.com/platform/frameworks/av/+/android-8.0.0_r1/services/audiopolicy/enginedefault/src/Engine.cpp#477
audiopolicy works this way: first it finds "strategy" for a stream using
Engine::getStrategyForStream
function, then it goes intoEngine::getDeviceForStrategyInt
to pick a device for this strategy.It seems that both
STREAM_SYSTEM
andSTREAM_MUSIC
use the sameSTRATEGY_MEDIA
:https://android.googlesource.com/platform/frameworks/av/+/android-8.0.0_r1/services/audiopolicy/enginedefault/src/Engine.cpp#180
So you would have to change something if you want to exclude system sound, but leave music playback on remote submix.