1 <html devsite> 2 <head> 3 <title>Configuring Audio Policies</title> 4 <meta name="project_path" value="/_project.yaml" /> 5 <meta name="book_path" value="/_book.yaml" /> 6 </head> 7 <body> 8 <!-- 9 Copyright 2017 The Android Open Source Project 10 11 Licensed under the Apache License, Version 2.0 (the "License"); 12 you may not use this file except in compliance with the License. 13 You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 --> 23 24 25 26 <p>Android 7.0 introduces a new audio policy configuration file format (XML) for 27 describing your audio topology.</p> 28 29 <p>Previous Android releases required using the 30 <code>device/<company>/<device>/audio/audio_policy.conf</code> 31 to declare the audio devices present on your product (you can see an example of 32 this file for the Galaxy Nexus audio hardware in 33 <code>device/samsung/tuna/audio/audio_policy.conf</code>). However, .conf is a 34 simple proprietary format that is too limited to describe complex topologies for 35 applications such as televisions and automobiles.</p> 36 37 <p>Android 7.0 deprecates the <code>audio_policy.conf</code> and adds support 38 for defining audio topology using an XML file format that is more 39 human-readable, has a wide range of editing and parsing tools, and is flexible 40 enough to describe complex audio topologies.</p> 41 42 <p class="note".<strong>Note:</strong> Android 7.0 preserves support for using 43 <code>audio_policy.conf</code>; this legacy format is used by default. To use 44 the XML file format, include the build option <code>USE_XML_AUDIO_POLICY_CONF 45 := 1</code> in device makefile.</p> 46 47 <h2 id=xml_advantages>Advantages of the XML format</h2> 48 <p>As in the .conf file, the new XML file enables defining the number and types 49 of output an input stream profiles, devices usable for playback and capture, and 50 audio attributes. In addition, the XML format offers the following enhancements: 51 </p> 52 53 <ul> 54 <li>Audio profiles are now structured similar to HDMI Simple Audio Descriptors 55 and enable a different set of sampling rates/channel masks for each audio 56 format.</li> 57 <li>Explicit definitions of all possible connections between devices and 58 streams. Previously, an implicit rule made it possible to interconnect all 59 devices attached to the same HAL module, preventing the audio policy from 60 controlling connections requested with audio patch APIs. In the XML format, the 61 topology description now defines connection limitations.</li> 62 <li>Support for <em>includes</em> avoids repeating standard A2DP, USB, or 63 reroute submit definitions.</li> 64 <li>Customizable volume curves. Previously, volume tables were hardcoded. In the 65 XML format, volume tables are described and can be customized.</li> 66 </ul> 67 68 <p>The template at 69 <code>frameworks/av/services/audiopolicy/config/audio_policy_configuration.xml</code> 70 shows many of these features in use.</p> 71 72 <h2 id=xml_file_format>File format and location</h2> 73 <p>The new audio policy configuration file is 74 <code>audio_policy_configuration.xml</code> and is located in 75 <code>/system/etc</code>. To view a simple audio policy configuration in the new 76 XML file format, view the example below.</p> 77 78 <section class="expandable"> 79 <h4 class="showalways">Show audio policy example</h4> 80 <pre class="devsite-click-to-copy"> 81 <?xml version="1.0" encoding="UTF-8" standalone="yes"?> 82 <audioPolicyConfiguration version="1.0" xmlns:xi="http://www.w3.org/2001/XInclude"> 83 <globalConfiguration speaker_drc_enabled="true"/> 84 <modules> 85 <module name="primary" halVersion="3.0"> 86 <attachedDevices> 87 <item>Speaker</item> 88 <item>Earpiece</item> 89 <item>Built-In Mic</item> 90 </attachedDevices> 91 <defaultOutputDevice>Speaker</defaultOutputDevice> 92 <mixPorts> 93 <mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY"> 94 <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" 95 samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> 96 </mixPort> 97 <mixPort name="primary input" role="sink"> 98 <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" 99 samplingRates="8000,16000,48000" 100 channelMasks="AUDIO_CHANNEL_IN_MONO"/> 101 </mixPort> 102 </mixPorts> 103 <devicePorts> 104 <devicePort tagName="Earpiece" type="AUDIO_DEVICE_OUT_EARPIECE" role="sink"> 105 <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" 106 samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/> 107 </devicePort> 108 <devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER" address=""> 109 <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" 110 samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> 111 </devicePort> 112 <devicePort tagName="Wired Headset" type="AUDIO_DEVICE_OUT_WIRED_HEADSET" role="sink"> 113 <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" 114 samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/> 115 </devicePort> 116 <devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source"> 117 <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" 118 samplingRates="8000,16000,48000" 119 channelMasks="AUDIO_CHANNEL_IN_MONO"/> 120 </devicePort> 121 <devicePort tagName="Wired Headset Mic" type="AUDIO_DEVICE_IN_WIRED_HEADSET" role="source"> 122 <profile name="" format="AUDIO_FORMAT_PCM_16_BIT" 123 samplingRates="8000,16000,48000" 124 channelMasks="AUDIO_CHANNEL_IN_MONO"/> 125 </devicePort> 126 </devicePorts> 127 <routes> 128 <route type="mix" sink="Earpiece" sources="primary output"/> 129 <route type="mix" sink="Speaker" sources="primary output"/> 130 <route type="mix" sink="Wired Headset" sources="primary output"/> 131 <route type="mix" sink="primary input" sources="Built-In Mic,Wired Headset Mic"/> 132 </routes> 133 </module> 134 <xi:include href="a2dp_audio_policy_configuration.xml"/> 135 </modules> 136 137 <xi:include href="audio_policy_volumes.xml"/> 138 <xi:include href="default_volume_tables.xml"/> 139 </audioPolicyConfiguration> 140 </pre></section> 141 142 <p>The top level structure contains modules that correspond to each audio HAL 143 hardware module, where each module has a list of mix ports, device ports, and 144 routes:</p> 145 <ul> 146 <li><strong>Mix ports</strong> describe the possible config profiles for streams 147 that can be opened at the audio HAL for playback and capture.</li> 148 <li><strong>Device ports</strong> describe the devices that can be attached with 149 their type (and optionally address and audio properties, if relevant).</li> 150 <li><strong>Routes</strong> (new) is now separated from the mix port descriptor, 151 enabling description of routes from device to device or stream to device.</li> 152 </ul> 153 154 <p>Volume tables are simple lists of points defining the curve used to translate 155 form a UI index to a volume in dB. A separate include file provides default 156 curves, but each curve for a given use case and device category can be 157 overwritten.</p> 158 159 <section class="expandable"> 160 <h4 class="showalways">Show volume table example</h4> 161 <pre class="devsite-click-to-copy"> 162 <?xml version="1.0" encoding="UTF-8"?> 163 <volumes> 164 <reference name="FULL_SCALE_VOLUME_CURVE"> 165 <point>0,0</point> 166 <point>100,0</point> 167 </reference> 168 <reference name="SILENT_VOLUME_CURVE"> 169 <point>0,-9600</point> 170 <point>100,-9600</point> 171 </reference> 172 <reference name="DEFAULT_VOLUME_CURVE"> 173 <point>1,-4950</point> 174 <point>33,-3350</point> 175 <point>66,-1700</point> 176 <point>100,0</point> 177 </reference> 178 </volumes> 179 </pre></section> 180 181 <section class="expandable"> 182 <h4 class="showalways">Show volumes example</h4> 183 <pre class="devsite-click-to-copy"> 184 <?xml version="1.0" encoding="UTF-8"?> 185 <volumes> 186 <volume stream="AUDIO_STREAM_VOICE_CALL" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 187 <volume stream="AUDIO_STREAM_VOICE_CALL" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 188 <volume stream="AUDIO_STREAM_VOICE_CALL" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 189 <volume stream="AUDIO_STREAM_VOICE_CALL" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 190 191 <volume stream="AUDIO_STREAM_SYSTEM" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 192 <volume stream="AUDIO_STREAM_SYSTEM" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 193 <volume stream="AUDIO_STREAM_SYSTEM" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 194 <volume stream="AUDIO_STREAM_SYSTEM" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 195 196 <volume stream="AUDIO_STREAM_RING" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 197 <volume stream="AUDIO_STREAM_RING" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 198 <volume stream="AUDIO_STREAM_RING" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 199 <volume stream="AUDIO_STREAM_RING" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA"ref="DEFAULT_VOLUME_CURVE"/> 200 201 <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 202 <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_SPEAKER"> 203 <point>1,-5500</point> 204 <point>20,-4300</point> 205 <point>86,-1200</point> 206 <point>100,0</point> 207 </volume> 208 <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 209 <volume stream="AUDIO_STREAM_MUSIC" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 210 211 <volume stream="AUDIO_STREAM_ALARM" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 212 <volume stream="AUDIO_STREAM_ALARM" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 213 <volume stream="AUDIO_STREAM_ALARM" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 214 <volume stream="AUDIO_STREAM_ALARM" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 215 216 <volume stream="AUDIO_STREAM_NOTIFICATION" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 217 <volume stream="AUDIO_STREAM_NOTIFICATION" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 218 <volume stream="AUDIO_STREAM_NOTIFICATION" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 219 <volume stream="AUDIO_STREAM_NOTIFICATION" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 220 221 <volume stream="AUDIO_STREAM_BLUETOOTH_SCO" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 222 <volume stream="AUDIO_STREAM_BLUETOOTH_SCO" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 223 <volume stream="AUDIO_STREAM_BLUETOOTH_SCO" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 224 <volume stream="AUDIO_STREAM_BLUETOOTH_SCO" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 225 226 <volume stream="AUDIO_STREAM_ENFORCED_AUDIBLE" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 227 <volume stream="AUDIO_STREAM_ENFORCED_AUDIBLE" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 228 <volume stream="AUDIO_STREAM_ENFORCED_AUDIBLE" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 229 <volume stream="AUDIO_STREAM_ENFORCED_AUDIBLE" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 230 231 <volume stream="AUDIO_STREAM_DTMF" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 232 <volume stream="AUDIO_STREAM_DTMF" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 233 <volume stream="AUDIO_STREAM_DTMF" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 234 <volume stream="AUDIO_STREAM_DTMF" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 235 236 <volume stream="AUDIO_STREAM_TTS" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="SILENT_VOLUME_CURVE"/> 237 <volume stream="AUDIO_STREAM_TTS" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="FULL_SCALE_VOLUME_CURVE"/> 238 <volume stream="AUDIO_STREAM_TTS" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="SILENT_VOLUME_CURVE"/> 239 <volume stream="AUDIO_STREAM_TTS" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="SILENT_VOLUME_CURVE"/> 240 241 <volume stream="AUDIO_STREAM_ACCESSIBILITY" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="DEFAULT_VOLUME_CURVE"/> 242 <volume stream="AUDIO_STREAM_ACCESSIBILITY" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="DEFAULT_VOLUME_CURVE"/> 243 <volume stream="AUDIO_STREAM_ACCESSIBILITY" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="DEFAULT_VOLUME_CURVE"/> 244 <volume stream="AUDIO_STREAM_ACCESSIBILITY" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="DEFAULT_VOLUME_CURVE"/> 245 246 <volume stream="AUDIO_STREAM_REROUTING" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="FULL_SCALE_VOLUME_CURVE"/> 247 <volume stream="AUDIO_STREAM_REROUTING" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="FULL_SCALE_VOLUME_CURVE"/> 248 <volume stream="AUDIO_STREAM_REROUTING" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="FULL_SCALE_VOLUME_CURVE"/> 249 <volume stream="AUDIO_STREAM_REROUTING" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="FULL_SCALE_VOLUME_CURVE"/> 250 251 <volume stream="AUDIO_STREAM_PATCH" deviceCategory="DEVICE_CATEGORY_HEADSET" ref="FULL_SCALE_VOLUME_CURVE"/> 252 <volume stream="AUDIO_STREAM_PATCH" deviceCategory="DEVICE_CATEGORY_SPEAKER" ref="FULL_SCALE_VOLUME_CURVE"/> 253 <volume stream="AUDIO_STREAM_PATCH" deviceCategory="DEVICE_CATEGORY_EARPIECE" ref="FULL_SCALE_VOLUME_CURVE"/> 254 <volume stream="AUDIO_STREAM_PATCH" deviceCategory="DEVICE_CATEGORY_EXT_MEDIA" ref="FULL_SCALE_VOLUME_CURVE"/> 255 </volumes> 256 </pre></section> 257 258 <h2 id=file_inclusions>File inclusions</h2> 259 <p>The XML Inclusions (XInclude) method can be used to include audio policy 260 configuration information located in other XML files. All included files must 261 follow the structure described above with the following restrictions:</p> 262 <ul> 263 <li>Files can contain only top-level elements.</li> 264 <li>Files cannot contain Xinclude elements.</li> 265 </ul> 266 <p>Use includes to avoid copying standard Android Open Source Project (AOSP) 267 audio HAL modules configuration information to all audio policy configuration 268 files (which is prone to errors). A standard audio policy configuration xml file 269 is provided for the following audio HALs:</p> 270 <ul> 271 <li><strong>A2DP:</strong> <code>a2dp_audio_policy_configuration.xml</code></li> 272 <li><strong>Reroute submix:</strong> <code>rsubmix_audio_policy_configuration.xml</code></li> 273 <li><strong>USB:</strong> <code>usb_audio_policy_configuration.xml</code></li> 274 </ul> 275 276 <h2 id=code_reorg>Audio policy code reorganization</h2> 277 <p>Android 7.0 splits <code>AudioPolicyManager.cpp</code> into several modules 278 to make it more maintainable and to highlight what is configurable. The new 279 organization of <code>frameworks/av/services/audiopolicy</code> includes the 280 following modules:</p> 281 282 <table> 283 <tr> 284 <th>Module</th> 285 <th>Description</th> 286 </tr> 287 288 <tr> 289 <td><code>/managerdefault</code></td> 290 <td>Includes the generic interfaces and behavior implementation common to all 291 applications. Similar to <code>AudioPolicyManager.cpp</code> with engine 292 functionality and common concepts abstracted away.</td> 293 </tr> 294 295 <tr> 296 <td><code>/common</code></td> 297 <td>Defines base classes (e.g data structures for input output audio stream 298 profiles, audio device descriptors, audio patches, audio port, etc.). Previously 299 defined inside <code>AudioPolicyManager.cpp</code>.</td> 300 </tr> 301 302 <tr> 303 <td><code>/engine</code></td> 304 <td><p>Implements the rules that define which device and volumes should be used for 305 a given use case. It implements a standard interface with the generic part, such 306 as to get the appropriate device for a given playback or capture use case, or to 307 set connected devices or external state (i.e. a call state of forced usage) that 308 can alter the routing decision.</p> 309 <p>Available in two versions, customized and default; use build option 310 <code>USE_CONFIGURABLE_AUDIO_POLICY</code> to select.</p></td> 311 </tr> 312 313 <tr> 314 <td><code>/engineconfigurable</code></td> 315 <td>Policy engine implementation that relies on parameter framework (see below). 316 Configuration is based on the parameter framework and where the policy is 317 defined by XML files.</td> 318 </tr> 319 320 <tr> 321 <td><code>/enginedefault</code></td> 322 <td>Policy engine implementation based on previous Android Audio Policy Manager 323 implementations. This is the default and includes hard coded rules that 324 correspond to current Nexus and AOSP implementations.</td> 325 </tr> 326 327 <tr> 328 <td><code>/service</code></td> 329 <td>Includes binder interfaces, threading and locking implementation with 330 interface to the rest of the framework.</td> 331 </tr> 332 333 </table> 334 335 <h2 id=policy_config>Configuration using parameter-framework</h2> 336 <p>Android 7.0 reorganizes audio policy code to make it easier to understand and 337 maintain while also supporting an audio policy defined entirely by configuration 338 files. The reorganization and audio policy design is based on Intel's parameter 339 framework, a plugin-based and rule-based framework for handling parameters.</p> 340 341 <p>Using the new configurable audio policy enables vendors OEMs to:</p> 342 <ul> 343 <li>Describe a system's structure and its parameters in XML.</li> 344 <li>Write (in C++) or reuse a backend (plugin) for accessing described 345 parameters.</li> 346 <li>Define (in XML or in a domain-specific language) conditions/rules upon which 347 a given parameter must take a given value.</li> 348 </ul> 349 350 <p>AOSP includes an example of an audio policy configuration file that uses the parameter-framework at: <code>Frameworks/av/services/audiopolicy/engineconfigurable/parameter-framework/example/Settings/PolicyConfigurableDomains.xml</code>. For 351 details, refer to Intel documentation on the 352 <a href="https://github.com/01org/parameter-framework">parameter-framework</a> 353 and 354 <a href="http://01org.github.io/parameter-framework/hosting/Android_M_Configurable_Audio_Policy.pdf">Android 355 Configurable Audio Policy</a>.</p> 356 357 <h2 id=policy_routing_apis>Audio policy routing APIs</h2> 358 <p>Android 6.0 introduced a public Enumeration and Selection API that sits on 359 top of the audio patch/audio port infrastructure and allows application 360 developers to indicate a preference for a specific device output or input for 361 connected audio records or tracks.</p> 362 <p>In Android 7.0, the Enumeration and Selection API is verified by CTS tests 363 and is extended to include routing for native C/C++ (OpenSL ES) audio streams. 364 The routing of native streams continues to be done in Java, with the addition of 365 an <code>AudioRouting</code> interface that supersedes, combines, and deprecates 366 the explicit routing methods that were specific to <code>AudioTrack</code> and 367 <code>AudioRecord</code> classes.</p> 368 369 <p>For details on the Enumeration and Selection API, refer to 370 <a href="https://developer.android.com/ndk/guides/audio/opensl-for-android.html?hl=fi#configuration-interface">Android 371 configuration interfaces</a> and <code>OpenSLES_AndroidConfiguration.h</code>. 372 For details on audio routing, refer to 373 <a href="https://developer.android.com/reference/android/media/AudioRouting.html">AudioRouting</a>. 374 </p> 375 376 <h2 id=multichannel>Multi-channel support</h2> 377 378 <p>If your hardware and driver supports multichannel audio via HDMI, you can 379 output the audio stream directly to the audio hardware (this bypasses the 380 AudioFlinger mixer so it doesn't get downmixed to two channels.) The audio HAL 381 must expose whether an output stream profile supports multichannel audio 382 capabilities. If the HAL exposes its capabilities, the default policy manager 383 allows multichannel playback over HDMI. For implementation details, see 384 <code>device/samsung/tuna/audio/audio_hw.c</code>.</p> 385 386 <p>To specify that your product contains a multichannel audio output, edit the 387 audio policy configuration file to describe the multichannel output for your 388 product. The following example from a Galaxy Nexus shows a <em>dynamic</em> 389 channel mask, which means the audio policy manager queries the actual channel 390 masks supported by the HDMI sink after connection.</p> 391 392 <pre class="devsite-click-to-copy"> 393 audio_hw_modules { 394 primary { 395 outputs { 396 ... 397 hdmi { 398 sampling_rates 44100|48000 399 channel_masks dynamic 400 formats AUDIO_FORMAT_PCM_16_BIT 401 devices AUDIO_DEVICE_OUT_AUX_DIGITAL 402 flags AUDIO_OUTPUT_FLAG_DIRECT 403 } 404 ... 405 } 406 ... 407 } 408 ... 409 } 410 </pre> 411 412 <p>You can also specify a static channel mask such as 413 <code>AUDIO_CHANNEL_OUT_5POINT1</code>. AudioFlinger's mixer downmixes the 414 content to stereo automatically when sent to an audio device that does not 415 support multichannel audio.</p> 416 417 <h2 id=codecs>Media codecs</h2> 418 419 <p>Ensure the audio codecs your hardware and drivers support are properly 420 declared for your product. For details, see 421 <a href="/devices/media/index.html#expose">Exposing Codecs to the 422 Framework</a>.</p> 423 424 </body> 425 </html> 426