搜索

41

主题

45

帖子

437

积分

中级会员

Rank: 3Rank: 3

积分
437
发表于 2020-5-23 11:15:50 7412 浏览 0 回复

mic占用问题。 前后Camera同时录制。

当多个应用同时使用mic时导致程序奔溃,是因为系统默认mic为独占资源,不可被多个应用或者一个应用中的多个实列同时使用。
修改记录:android8.1
  1. frameworks\av\services\audiopolicy\managerdefault\AudioPolicyManager.cpp
  2. 1. audio_io_handle_t AudioPolicyManager::getInputForDevice()方法如下位置添加
  3.                         if (address == "") {
  4.                                 DeviceVector inputDevices = mAvailableInputDevices.getDevicesFromType(device);
  5.                                 //   the inputs vector must be of size 1, but we don't want to crash here
  6.                                 address = inputDevices.size() > 0 ? inputDevices.itemAt(0)->mAddress : String8("");
  7.                         }
  8.                         //add by jyj
  9.                         // Modify Tower 20190612: check wether have an AudioInputDescriptor Use the same profile
  10.                         for (size_t input_index = 0; input_index < mInputs.size(); input_index++) {
  11.                                 sp<AudioInputDescriptor> desc;
  12.                                 desc = mInputs.valueAt(input_index);
  13.                                 if (desc->mProfile == profile) {
  14.                                         audioSession->changeActiveCount(1);    // reference count add
  15.                                         desc->addAudioSession(session, audioSession);
  16.                                         return desc->mIoHandle;
  17.                                 }
  18.                         }
  19.                         //end by jyj
  20. 2.status_t AudioPolicyManager::startInput()注释如下代码段
  21.                         #else
  22.                         /*if (!is_virtual_input_device(inputDesc->mDevice))
  23.                                 .....
  24.                                 .....注释的代码段
  25.                         
  26.                           }*/
  27.                         #endif
复制代码

修改之后本人试过camera前后摄像头同时录制视频。。。
回复

使用道具 举报

返回列表
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


登录或注册
快速回复 返回顶部 返回列表