[Android] [Audio] audio_policy.conf file analysis

Source: Internet
Author: User

  Different Android products often differ in the design of audio, and these differences can be obtained with the audio_policy.conf profile. There are two locations for audio profile storage in the Android system, and the storage address can be found in the AudioPolicyManagerBase.cpp file:

#define Audio_policy_vendor_config_file  #define audio_policy_config_file         "/system/etc/audio_ Policy.conf "

You can know in the AudioPolicyManager.cpp file that the system will load the Configure file in the Vendor/etc directory first, and then load the Configure file under the System/etc directory. If both loading errors occur, the system will load the default configuration file and be named Primary module, from which it can be seen that the module that must exist in the audio system is primary.

1     if (Loadaudiopolicyconfig (audio_policy_vendor_config_file)! = no_error) {2         if (Loadaudiopolicyconfig (audio_policy_config_file)! = no_error) {3             Aloge ("could not load audio policy configuration file, setting defaults"); 4             defaultaudiopolicyconfig (); 5         }6     }

"Excerpt audio_policy.conf"

1 # Global configuration section:lists input and output devices always present on the device2# asWell asThe output device selected bydefault.3# Devices is designated by astringThat corresponds to theenum inchaudio.h4 5 global_configuration {6 attached_output_devices Audio_device_out_speaker7 Default_output_device Audio_device_out_speaker8Attached_input_devices audio_device_in_builtin_mic| audio_device_in_voice_call|Audio_device_in_remote_submix9 custom_properties {TenVoice_volume_applied_after_mixing_in_calltrue OneVoice_volume_applied_after_mixing_in_communicationfalse Ain_call_music_attenuation_db6 -     } - } the  -# audio Hardware Module Section:contains descriptors forAll audio HW modules present on the -# device. Each HW module node isNamed after the corresponding HW module libraryBasename. -# for instance,"Primary"Corresponds to Audio.primary.<device>. So. +# the"Primary"Module ismandatory and must include at least one output with - # audio_output_flag_primary FLAG. + # Each module descriptor contains one or more output profiles descriptors and zero or more A # Input profile descriptors. Each profiles lists all the parameters supported by a given output at # or input stream category. -# the"Channel_masks","formats","Devices"and"Flags"is specifiedusingstrings corresponding -# to EnumsinchAudio.h and Audio_policy.h. They is concatenated by use of"|"Without space or"\ n". -  - Audio_hw_modules { - Primary { in Outputs { - Primary { toSampling_rates48000 + channel_masks Audio_channel_out_stereo - formats Audio_format_pcm_16_bit theDevices audio_device_out_speaker| Audio_device_out_wired_headset| audio_device_out_wired_headphone|Audio_device_out_all_sco * Flags Audio_output_flag_primary $       }Panax Notoginseng Deep_buffer { -Sampling_rates48000 the channel_masks Audio_channel_out_stereo + formats Audio_format_pcm_16_bit ADevices audio_device_out_speaker| Audio_device_out_wired_headset|Audio_device_out_wired_headphone the Flags Audio_output_flag_deep_buffer +       } -     } $ Inputs { $ Primary { -Sampling_rates8000|11025|12000|16000|22050|24000|32000|44100|48000 -Channel_masks audio_channel_in_mono|Audio_channel_in_stereo the 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_voice_callWuyi       } the     } -   } Wu A2DP { - Outputs { About A2DP { $Sampling_rates44100 - channel_masks Audio_channel_out_stereo - formats Audio_format_pcm_16_bit - Devices AUDIO_DEVICE_OUT_ALL_A2DP A       } +     } the   } - HDMI { $ Outputs { the Hdmi_stereo { theSampling_rates48000 the channel_masks Audio_channel_out_stereo the formats Audio_format_pcm_16_bit - Devices Audio_device_out_aux_digital in       } the Hdmi_multi { theSampling_rates32000|44100|48000|88200|96000 About # channel_masks Audio_channel_out_5point1 the channel_masks Dynamic the formats Audio_format_pcm_16_bit the Devices Audio_device_out_aux_digital + Flags Audio_output_flag_direct -       } the     }Bayi   } the R_submix { the Outputs { - Submix { -Sampling_rates48000 the channel_masks Audio_channel_out_stereo the formats Audio_format_pcm_16_bit the Devices Audio_device_out_remote_submix the       } -     } the Inputs { the Submix { theSampling_rates4800094 channel_masks Audio_channel_in_stereo the formats Audio_format_pcm_16_bit the Devices Audio_device_in_remote_submix the       }98     } About   } - Hs_usb {101 Outputs {102 USB_DGTL {103Sampling_rates44100|48000104 channel_masks Audio_channel_out_stereo the formats Audio_format_pcm_16_bit106 Devices Audio_device_out_dgtl_dock_headset107         }108     }109   } the USB {111 Outputs { the Usb_accessory {113Sampling_rates44100 the channel_masks Audio_channel_out_stereo the formats Audio_format_pcm_16_bit the Devices Audio_device_out_usb_accessory117       }118 # usb_device {119# sampling_rates44100 - # channel_masks Audio_channel_out_stereo121 # formats Audio_format_pcm_16_bit122 # devices Audio_device_out_usb_device123 #      }124     } the   }}

  From the audio_policy.conf file can be found that the system contains primary, A2DP, USB and other audio interfaces, corresponding to the audio.<primary/a2dp/usb>.<device>.so in the system. Several outputs & inputs are included in each audio interface, and each output or input contains several devices, as well as information such as sampling frequency, number of channels, and so on. These devices information, sampling frequency information & channel information will be stored in the ioprofile of the respective module. As described in the audio_policy.conf configuration file above, 6 modules (EG.PRIMARY,A2DP,HDMI,R_SUBMIX,HS_USB & USB) and 7 outputs are generated at the end of the system. In Audio_device_out_speaker , for example, the device defines the IOProfile1 in which outputs belongs in the primary module, and so on.

The architecture of the audio module can be simplified according to the audio_policy.conf file, as shown in 1:

Figure 1

[Android] [Audio] audio_policy.conf file analysis

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.