audio policy: fix capture indication to sound trigger service.
Only indicate active capture to sound trigger service
when capturing from primay HW module.
Bug: 31826453
Bug: 31771879
Change-Id: Idf92393d3e7dbf926b847ab23f670e7ab5dd5248
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index ac4ea87..968b80f 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -1688,10 +1688,15 @@
MIX_STATE_MIXING);
}
- if (mInputs.activeInputsCount() == 0) {
+ // indicate active capture to sound trigger service if starting capture from a mic on
+ // primary HW module
+ audio_devices_t device = getNewInputDevice(input);
+ audio_devices_t primaryInputDevices = availablePrimaryInputDevices();
+ if (((device & primaryInputDevices & ~AUDIO_DEVICE_BIT_IN) != 0) &&
+ mInputs.activeInputsCountOnDevices(primaryInputDevices) == 0) {
SoundTrigger::setCaptureState(true);
}
- setInputDevice(input, getNewInputDevice(input), true /* force */);
+ setInputDevice(input, device, true /* force */);
// automatically enable the remote submix output when input is started if not
// used by a policy mix of type MIX_TYPE_RECORDERS
@@ -1768,9 +1773,14 @@
}
}
+ audio_devices_t device = inputDesc->mDevice;
resetInputDevice(input);
- if (mInputs.activeInputsCount() == 0) {
+ // indicate inactive capture to sound trigger service if stopping capture from a mic on
+ // primary HW module
+ audio_devices_t primaryInputDevices = availablePrimaryInputDevices();
+ if (((device & primaryInputDevices & ~AUDIO_DEVICE_BIT_IN) != 0) &&
+ mInputs.activeInputsCountOnDevices(primaryInputDevices) == 0) {
SoundTrigger::setCaptureState(false);
}
inputDesc->clearPreemptedSessions();