Reset audio port generation when having recording callback event.

In RecordingActivityMonitor, compare audio device type and address to
know if legacy remote submix is active, which requires querying audio
patches. When there is a recording callback event, the audio patches in
AudioManager may not be up to date. In that case, when getting a
recording callback event, reset audio port generation if the patch
handle is not found in the cached audio patches.

Test: repro steps in the bug
Bug: 144063329
Change-Id: Ife5c9a65243d2e85e4cd9480e3b415f8bfddc6f5
This commit is contained in:
jiabin
2020-04-28 16:19:47 -07:00
parent 840d47d144
commit fa7a0252b0

View File

@@ -686,6 +686,23 @@ public class AudioSystem
String effectName = effects.length == 0 ? "None" : effects[0].name;
if (cb != null) {
ArrayList<AudioPatch> audioPatches = new ArrayList<>();
if (AudioManager.listAudioPatches(audioPatches) == AudioManager.SUCCESS) {
boolean patchFound = false;
int patchHandle = recordingFormat[6];
for (AudioPatch patch : audioPatches) {
if (patch.id() == patchHandle) {
patchFound = true;
break;
}
}
if (!patchFound) {
// The cached audio patches in AudioManager is not up-to-date.
// Reset audio port generation to ensure callback side can
// get up-to-date audio port information.
AudioManager.resetAudioPortGeneration();
}
}
// TODO receive package name from native
cb.onRecordingConfigurationChanged(event, riid, uid, session, source, portId, silenced,
recordingFormat, clientEffects, effects, activeSource, "");