赞
踩
audio policy xml里面有2种角色:source和sink,每种角色又分为devicePorts和mixPorts。
type为AUDIO_PORT_TYPE_DEVICE
devicePorts(source):为实际的硬件输入设备,对应安卓的role为AUDIO_PORT_ROLE_SOURCE ;
devicePorts(sink):为实际的硬件输出设备,对应安卓的role为AUDIO_PORT_ROLE_SINK ;
type为AUDIO_PORT_TYPE_MIX
mixPorts(source):为AudioFlinger中的播放(AudioTrack)的线程,对应安卓的role为AUDIO_PORT_ROLE_SOURCE,mOutputs;
mixPorts(sink):为AudioFlinger中的录音(AudioRecord)的线程,对应安卓的role为AUDIO_PORT_ROLE_SINK,mInputs
routes:定义devicePort和mixPorts的路由策略。
通过该接口AudioSystem.listAudioPorts可获取到当前所有的端口
status_t AudioPolicyManager::listAudioPorts(audio_port_role_t role, audio_port_type_t type, unsigned int *num_ports, struct audio_port *ports, unsigned int *generation) { ... if (type == AUDIO_PORT_TYPE_NONE || type == AUDIO_PORT_TYPE_DEVICE) { // do not report devices with type AUDIO_DEVICE_IN_STUB or AUDIO_DEVICE_OUT_STUB // as they are used by stub HALs by convention if (role == AUDIO_PORT_ROLE_SINK || role == AUDIO_PORT_ROLE_NONE) { for (const auto& dev : mAvailableOutputDevices) { if (dev->type() == AUDIO_DEVICE_OUT_STUB) { continue; } if (portsWritten < portsMax) { dev->toAudioPort(&ports[portsWritten++]); ALOGD("[%s:%d] output device role:%d, name:%s, type:%#x", __func__, __LINE__, ports[portsWritten-1].role, ports[portsWritten-1].name, ports[portsWritten-1].ext.device.type); } (*num_ports)++; } } if (role == AUDIO_PORT_ROLE_SOURCE || role == AUDIO_PORT_ROLE_NONE) { for (const auto& dev : mAvailableInputDevices) { if (dev->type() == AUDIO_DEVICE_IN_STUB) { continue; } if (portsWritten < portsMax) { dev->toAudioPort(&ports[portsWritten++]); ALOGD("[%s:%d] input device role:%d, name:%s, type:%#x", __func__, __LINE__, ports[portsWritten-1].role, ports[portsWritten-1].name, ports[portsWritten-1].ext.device.type); } (
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。