Android Audio - 支持多应用同时录音_Android4.4修改方法

支持多应用同时录音_Android4.4修改方法

修改方法

  • AudioFlinger修改
    相关源码太多, 已经上传到 Github. 希望能够给您帮助 😄

git clone https://github.com/iFinelioTower/CSDN -b android4.4_multapprecording_support

  • AudioPolicy修改
    源码路径: 需要做三处修改
    sdk\hardware\libhardware_legacy\audio\AudioPolicyManagerBase.cpp
    sdk\hardware\libhardware_legacy\include\hardware_legacy\AudioPolicyManagerBase.h
  1. 添加 AudioInputDescriptor::mIoHandle 变量
class AudioInputDescriptor
{
	public:
		AudioInputDescriptor(const IOProfile *profile);
		
		status_t    dump(int fd);
		
#ifdef ANDROID4_4_SUPPORT_MULIT_CHANNEL_RECORDING
		void setIoHandle(audio_io_handle_t ioHandle);
		audio_io_handle_t             mIoHandle;    // input handle
#endif
		
		uint32_t mSamplingRate;                     //
		audio_format_t mFormat;                     // input configuration
		audio_channel_mask_t mChannelMask;             //
		audio_devices_t mDevice;                    // current device this input is routed to
		uint32_t mRefCount;                         // number of AudioRecord clients using this output
		int      mInputSource;                      // input source selected by application (mediarecorder.h)
		const IOProfile *mProfile;                  // I/O profile this output derives from

};
  1. 添加设置 AudioInputDescriptor::mIoHandle 函数
    在 AudioPolicyManagerBase::StreamDescriptor::StreamDescriptor() 函数前添加
#ifdef ANDROID4_4_SUPPORT_MULIT_CHANNEL_RECORDING
	void AudioPolicyManagerBase::AudioInputDescriptor::setIoHandle(audio_io_handle_t ioHandle)
	{
	    mIoHandle = ioHandle;
	}
#endif
  1. 应用 mIoHandle 这个变量
在 audio_io_handle_t AudioPolicyManagerBase::getInput()
mpClientInterface->openInput 前添加:
#ifdef ANDROID4_4_SUPPORT_MULIT_CHANNEL_RECORDING
	// Modify Tower 20181103: check wether have an AudioInputDescriptor Use the same profile
	for (size_t input_index = 0; input_index < mInputs.size(); input_index++) {
		sp<AudioInputDescriptor> desc;
		desc = mInputs.valueAt(input_index);
		if (desc->mProfile == profile) {
			desc->mRefCount++;
			return desc->mIoHandle;
		} 
	}
#endif
在 audio_io_handle_t AudioPolicyManagerBase::getInput()
mInputs.add(input, inputDesc); 前添加:
#ifdef ANDROID4_4_SUPPORT_MULIT_CHANNEL_RECORDING
     inputDesc->setIoHandle(input); 
#endif

与之相关

Android Audio - 音频子系统框架简析
Android Audio - 支持多应用同时录音_Android5.1 & Android6.0 修改方法
Android Audio - 支持多应用同时录音_Android8.1修改方法

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值