Android支持多个应用同时录音

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值