title: What is the link between Usages and the Audio HAL?
body: <p>I am trying to get audio working on a board to which we're porting Android.</p>
  <p>Currently, sounds played with usages such as <code>USAGE_ALARM</code> (4) are audible, whereas sounds played with usages such as <code>USAGE_MEDIA</code> (1) are silent.</p>
  <p>For the audible usages, we can see calls to the Audio HAL:</p>
  <pre><code>...
  D AudioFlinger: Client defaulted notificationFrames to 11025 for frameCount 22050
  D AF::TrackHandle: OpPlayAudio: track:64 usage:4 not muted
  D audio_hw_primary: out_set_parameters: enter: kvpairs: routing=2
  D audio_hw_primary: out_set_parameters: exit: code(0)
  I audio_hw_primary: start_output_stream_primary... 0xf3856000, device 2, address , mode 0
  I audio_hw_primary: select_output_device(), headphone 0 ,headset 0 ,speaker 2, earpiece 0,
  I audio_hw_primary: get_card_for_device adev: 0xf3828000, device: 2, flag: 0, card_index: 0xf3856158
  W audio_hw_primary: card 0, port 0 device 0x2
  W audio_hw_primary: rate 48000, channel 2 period_size 0xc0
  W StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted
  ...
  </code></pre>
  <p>Whereas for silent usages, we see only:</p>
  <pre><code>...
  D AudioFlinger: Client defaulted notificationFrames to 11025 for frameCount 22050
  D AF::TrackHandle: OpPlayAudio: track:65 usage:1 not muted
  W StreamHAL: Error from HAL stream in function get_presentation_position: Operation not permitted
  ...
  </code></pre>
  <p>I thought that <code>/vendor/etc/audio_policy_configuration.xml</code> might be important.  I've paired it back to just having one output, but nothing has changed.</p>
  <pre><code>        &lt;attachedDevices&gt;
              &lt;item&gt;Speaker&lt;/item&gt;
          ...
          &lt;defaultOutputDevice&gt;Speaker&lt;/defaultOutputDevice&gt;
          &lt;mixPorts&gt;
              &lt;mixPort name=&quot;primary output&quot; role=&quot;source&quot; flags=&quot;AUDIO_OUTPUT_FLAG_PRIMARY&quot;&gt;
                  &lt;profile name=&quot;&quot; format=&quot;AUDIO_FORMAT_PCM_16_BIT&quot;
                           samplingRates=&quot;48000&quot; channelMasks=&quot;AUDIO_CHANNEL_OUT_STEREO&quot;/&gt;
          ...
          &lt;devicePorts&gt;
              &lt;devicePort tagName=&quot;Speaker&quot; type=&quot;AUDIO_DEVICE_OUT_SPEAKER&quot; role=&quot;sink&quot; &gt;
              &lt;/devicePort&gt;
          ...
          &lt;routes&gt;
              &lt;route type=&quot;mix&quot; sink=&quot;Speaker&quot;
                     sources=&quot;primary output&quot;/&gt;
  </code></pre>
  <p>What part of AOSP is responsible for the routing of different usages?</p>
  <p>Why do some work and other are silent?</p>