解析audio_policy.conf(android_audio)
Posted we1less
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了解析audio_policy.conf(android_audio)相关的知识,希望对你有一定的参考价值。
参考文章 https://blog.csdn.net/qq_33750826/article/details/82455026
/vendor/etc/audio_policy.conf 加载 或者 /system/etc/audio_policy.conf
audio_hw_modules {
primary { //一个module对应厂家提供的一个so文件
global_configuration {
attached_output_devices AUDIO_DEVICE_OUT_SPEAKER
default_output_device AUDIO_DEVICE_OUT_SPEAKER
attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC
audio_hal_version 3.0
}
devices {
speaker {
type AUDIO_DEVICE_OUT_SPEAKER
gains {
gain_1 {
mode AUDIO_GAIN_MODE_JOINT
min_value_mB -8400
max_value_mB 4000
default_value_mB 0
step_value_mB 100
}
}
}
}
outputs { //一个module里面可以有多个outputs
primary { //一个output里,表明参数
sampling_rates 48000
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices speaker //设备 喇叭
flags AUDIO_OUTPUT_FLAG_PRIMARY //这个代表是默认设备
}
}
inputs { //一个module里面可以有多个inputs
primary {
sampling_rates 8000|16000
channel_masks AUDIO_CHANNEL_IN_MONO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_IN_BUILTIN_MIC //设备 麦克
}
}
}
r_submix {
global_configuration {
attached_input_devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
audio_hal_version 2.0
}
outputs {
submix {
sampling_rates 48000
channel_masks AUDIO_CHANNEL_OUT_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_OUT_REMOTE_SUBMIX
}
}
inputs {
submix {
sampling_rates 48000
channel_masks AUDIO_CHANNEL_IN_STEREO
formats AUDIO_FORMAT_PCM_16_BIT
devices AUDIO_DEVICE_IN_REMOTE_SUBMIX
}
}
}
}
frameworks/av/services/audiopolicy/common/managerdefinitions/src/ConfigParsingUtils.cpp
cnode节点在 system/core/include/cutils/config_utils.h
typedef struct cnode cnode;
struct cnode
{
cnode *next;
cnode *first_child;
cnode *last_child;
const char *name;
const char *value;
};
//static
status_t ConfigParsingUtils::loadConfig(const char *path, AudioPolicyConfig &config)
{
cnode *root;
char *data;
data = (char *)load_file(path, NULL);
if (data == NULL) {
return -ENODEV;
}
root = config_node("", "");
config_load(root, data);
HwModuleCollection hwModules;
loadHwModules(root, hwModules, config);
// legacy audio_policy.conf files have one global_configuration section, attached to primary.
loadGlobalConfig(root, config, hwModules.getModuleFromName(AUDIO_HARDWARE_MODULE_ID_PRIMARY));
config.setHwModules(hwModules);
config_free(root);
free(root);
free(data);
ALOGI("loadAudioPolicyConfig() loaded %s\\n", path);
return NO_ERROR;
}
以上是关于解析audio_policy.conf(android_audio)的主要内容,如果未能解决你的问题,请参考以下文章