Android支持多个应用同时录音
Android 7.x和Android 8.1版本修改
共两个修改点:
(1) 修改函数:audio_io_handle_t AudioPolicyManager::getInputForDevice()
需要在mpClientInterface->openInput前添加如下代码:
#ifdef ANDROIDN_SUPPORT_MULIT_CHANNEL_RECORDING
for (size_t input_index = 0; input_index < mInputs.size(); input_index++) {
sp<AudioInputDescriptor> desc;
desc = mInputs.valueAt(input_index);
if (desc->mProfile == profile) {
audioSession->changeActiveCount(1);
desc->addAudioSession(session, audioSession);
return desc->mIoHandle;
}
}
#endif
(2)修改函数:status_t AudioPolicyManager::startInput()
注释掉以下代码段
#ifndef ANDROIDN_SUPPORT_MULTI_CHANNEL_RECORDING
// virtual input devices are compatible with other input devices
if (!is_virtual_input_device(inputDesc->mDevice)) {
// for a non-virtual input device, check if there is another (non-virtual) active input
audio_io_handle_t activeInput = mInputs.getActiveInput();
if (activeInput != 0 && activeInput != input) {
// If the already active input uses AUDIO_SOURCE_HOTWORD then it is closed,
// otherwise the active input continues and the new input cannot be started.
sp<AudioInputDescriptor> activeDesc = mInputs.valueFor(activeInput);
if ((activeDesc->inputSource() == AUDIO_SOURCE_HOTWORD) &&
!activeDesc->hasPreemptedSession(session)) {
ALOGW("startInput(%d) preempting low-priority input %d", input, activeInput);
//FIXME: consider all active sessions
AudioSessionCollection activeSessions = activeDesc->getActiveAudioSessions();
audio_sessi