原文件注釋說明:
# audio hardware module section: contains descriptors for all audio hw modules present on the # device. Each hw module node is named after the corresponding hw module library base name. # for instance, "primary" corresponds to audio.primary.<device>.so. # the "primary" module is mandatory and must include at least one output with # AUDIO_OUTPUT_FLAG_PRIMARY flag. # Each module descriptor contains one or more output profile descriptors and zero or more # input profile descriptors. Each profile lists all the parameters supported by a given output # or input stream category. # The "channel_masks", "formats", "devices" and "flags" are specified using strings corresponding # to enums in audio.h and audio_policy.h. They are concatenated by use of "|" without space or "\n".
其中文翻譯大致如下(不太精確,勿見怪~~):
音頻設備模塊部分:描述設備中包含所有音頻設備模塊。 每個音頻設備節點有着相應的設備模塊庫基本名稱; 例如:primary 對應着audio.primary.<devices>.so。 其中,"primary"是必須要有的,而且必須包含至少一個輸出 AUDIO_OUTPUT_FLAG_PRIMARY 標志。 每個模塊描述元包含一個或多個輸出配置描述元和一或多個輸入配置描述元。 每個配置通過給定的輸出或輸入流種類,列出所有支持的參數。 其中"channel_masks"、"formats"、"devices"和"flags"是由audio.h和audio_policy.h中相應的字符串指定的。 它們通過沒有空格的"|"或"\n"聯系起來。
其他博客的講解:[Form: http://www.tuicool.com/articles/7J73ae]
不同的Android產品在音頻的設計上通常是有差異的,利用配置文件的形式(audio_policy.conf)可以使廠商方便地描述其產品中所包含的音頻設備,這個文件的存放路徑有兩處: #define AUDIO_POLICY_VENDOR_CONFIG_FILE "/vendor/etc/audio_policy.conf" #define AUDIO_POLICY_CONFIG_FILE"/system/etc/audio_policy.conf"
聯想K860手機例子:
# Global configuration section: lists input and output devices always present on the device # as well as the output device selected by default. # Devices are designated by a string that corresponds to the enum in audio.h global_configuration { attached_output_devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER default_output_device AUDIO_DEVICE_OUT_SPEAKER attached_input_devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BACK_MIC } # audio hardware module section: contains descriptors for all audio hw modules present on the # device. Each hw module node is named after the corresponding hw module library base name. # for instance, "primary" corresponds to audio.primary.<device>.so. # the "primary" module is mandatory and must include at least one output with # AUDIO_OUTPUT_FLAG_PRIMARY flag. # Each module descriptor contains one or more output profile descriptors and zero or more # input profile descriptors. Each profile lists all the parameters supported by a given output # or input stream category. # The "channel_masks", "formats", "devices" and "flags" are specified using strings corresponding # to enums in audio.h and audio_policy.h. They are concatenated by use of "|" without space or "\n". audio_hw_modules { primary { outputs { primary { sampling_rates 48000 channel_masks AUDIO_CHANNEL_OUT_STEREO formats AUDIO_FORMAT_PCM_16_BIT devices AUDIO_DEVICE_OUT_EARPIECE|AUDIO_DEVICE_OUT_SPEAKER|AUDIO_DEVICE_OUT_WIRED_HEADSET|AUDIO_DEVICE_OUT_WIRED_HEADPHONE|AUDIO_DEVICE_OUT_ALL_SCO|AUDIO_DEVICE_OUT_LINEOUT1|AUDIO_DEVICE_OUT_LINEOUT2|AUDIO_DEVICE_OUT_FM flags AUDIO_OUTPUT_FLAG_PRIMARY } } inputs { primary { sampling_rates 8000|11025|12000|16000|22050|24000|32000|44100|48000 channel_masks AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_STEREO formats AUDIO_FORMAT_PCM_16_BIT devices AUDIO_DEVICE_IN_BUILTIN_MIC|AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_WIRED_HEADSET|AUDIO_DEVICE_IN_BACK_MIC|AUDIO_DEVICE_IN_LINEIN1|AUDIO_DEVICE_IN_LINEIN2 } } } a2dp { outputs { a2dp { sampling_rates 44100 channel_masks AUDIO_CHANNEL_OUT_STEREO formats AUDIO_FORMAT_PCM_16_BIT devices AUDIO_DEVICE_OUT_ALL_A2DP } } } }