修改方法
- 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
- 添加 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
};
- 添加设置 AudioInputDescriptor::mIoHandle 函数
在 AudioPolicyManagerBase::StreamDescriptor::StreamDescriptor() 函数前添加
#ifdef ANDROID4_4_SUPPORT_MULIT_CHANNEL_RECORDING
void AudioPolicyManagerBase::AudioInputDescriptor::setIoHandle(audio_io_handle_t ioHandle)
{
mIoHandle = ioHandle;
}
#endif
- 应用 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修改方法