tree: 5cdd70c4085a1b59ca7b8108a5987c4ad49ebee5 [path history] [tgz]
  1. meta/
  2. mixer/
  3. schema/
  4. test/
  5. testing/
  6. activity_dispatcher.cc
  7. activity_dispatcher.h
  8. activity_dispatcher_unittest.cc
  9. audio_admin.cc
  10. audio_admin.h
  11. audio_admin_unittest.cc
  12. audio_capturer.cc
  13. audio_capturer.h
  14. audio_capturer_unittest.cc
  15. audio_core_impl.cc
  16. audio_core_impl.h
  17. audio_device.cc
  18. audio_device.h
  19. audio_device_manager.cc
  20. audio_device_manager.h
  21. audio_device_settings.cc
  22. audio_device_settings.h
  23. audio_device_settings_unittest.cc
  24. audio_device_unittest.cc
  25. audio_driver.h
  26. audio_driver_unittest.cc
  27. audio_driver_v1.cc
  28. audio_driver_v2.cc
  29. audio_input.cc
  30. audio_input.h
  31. audio_input_unittest.cc
  32. audio_object.h
  33. audio_output.cc
  34. audio_output.h
  35. audio_output_unittest.cc
  36. audio_policy.h
  37. audio_renderer.cc
  38. audio_renderer.h
  39. audio_renderer_unittest.cc
  40. base_capturer.cc
  41. base_capturer.h
  42. base_renderer.cc
  43. base_renderer.h
  44. BUILD.gn
  45. context.cc
  46. context.h
  47. device_config.cc
  48. device_config.h
  49. device_config_unittest.cc
  50. device_registry.h
  51. driver_output.cc
  52. driver_output.h
  53. driver_output_unittest.cc
  54. driver_utils.cc
  55. driver_utils.h
  56. effects_stage.cc
  57. effects_stage.h
  58. effects_stage_unittest.cc
  59. format.cc
  60. format.h
  61. format_unittest.cc
  62. intermediate_buffer.cc
  63. intermediate_buffer.h
  64. intermediate_buffer_unittest.cc
  65. link_matrix.cc
  66. link_matrix.h
  67. link_matrix_unittest.cc
  68. loudness_transform.cc
  69. loudness_transform.h
  70. loudness_transform_unittest.cc
  71. main.cc
  72. mix_stage.cc
  73. mix_stage.h
  74. mix_stage_unittest.cc
  75. output_pipeline.cc
  76. output_pipeline.h
  77. output_pipeline_unittest.cc
  78. packet.cc
  79. packet.h
  80. packet_queue.cc
  81. packet_queue.h
  82. packet_queue_unittest.cc
  83. packet_unittest.cc
  84. pending_capture_buffer.cc
  85. pending_capture_buffer.h
  86. pending_flush_token.cc
  87. pending_flush_token.h
  88. pipeline_config.h
  89. plug_detector.cc
  90. plug_detector.h
  91. plug_detector_unittest.cc
  92. policy_loader.cc
  93. policy_loader.h
  94. policy_loader_fuzzer.cc
  95. policy_loader_unittest.cc
  96. policy_loader_unittest_data.h
  97. process_config.cc
  98. process_config.h
  99. process_config_loader.cc
  100. process_config_loader.h
  101. process_config_loader_unittest.cc
  102. process_config_unittest.cc
  103. profile_provider.cc
  104. profile_provider.h
  105. profile_provider_unittest.cc
  106. README.md
  107. reporter.cc
  108. reporter.h
  109. reporter_unittest.cc
  110. ring_buffer.cc
  111. ring_buffer.h
  112. ring_buffer_unittest.cc
  113. route_graph.cc
  114. route_graph.h
  115. route_graph_unittest.cc
  116. stream.h
  117. stream_usage.cc
  118. stream_usage.h
  119. stream_usage_unittest.cc
  120. stream_volume_manager.cc
  121. stream_volume_manager.h
  122. stream_volume_manager_unittest.cc
  123. tap_stage.cc
  124. tap_stage.h
  125. tap_stage_unittest.cc
  126. thermal_agent.cc
  127. thermal_agent.h
  128. thermal_agent_unittest.cc
  129. thermal_config.h
  130. threading_model.cc
  131. threading_model.h
  132. threading_model_unittest.cc
  133. throttle_output.h
  134. ultrasound_capturer.cc
  135. ultrasound_capturer.h
  136. ultrasound_factory.cc
  137. ultrasound_factory.h
  138. ultrasound_renderer.cc
  139. ultrasound_renderer.h
  140. usage_gain_reporter_impl.cc
  141. usage_gain_reporter_impl.h
  142. usage_gain_reporter_impl_unittest.cc
  143. usage_reporter_impl.cc
  144. usage_reporter_impl.h
  145. usage_reporter_impl_unittest.cc
  146. usage_settings.cc
  147. usage_settings.h
  148. usage_settings_unittest.cc
  149. utils.cc
  150. utils.h
  151. utils_unittest.cc
  152. versioned_timeline_function.h
  153. versioned_timeline_function_unittest.cc
  154. volume_control.cc
  155. volume_control.h
  156. volume_control_unittest.cc
  157. volume_curve.cc
  158. volume_curve.h
  159. volume_curve_unittest.cc
  160. wakeup_event.cc
  161. wakeup_event.h
  162. wakeup_event_unittest.cc
src/media/audio/audio_core/README.md

Audio Core

This is the core of the audio system. It implements the core FIDL APIs fuchsia.media.AudioCapturer and fuchsia.media.AudioRenderer. At a high level, audio core is organized as follows:

+---------------------+        +---------------------+
|   AudioRenderers    |        |    AudioCapturers   |
| r1   r2   ...   rN  |        | c1   c2   ...   cN  |
+---\---|----------|--+        +--Λ---ΛΛ-------------+
     \  |          |      +-------+  / |
      \ |          |   loopback     /  |
+------VV----------V--+   |    +---/---|-------------+
| o1   o2   ...   oN--+---+    | i1   i2   ...   iN  |
|    AudioOutputs     |        |     AudioInputs     |
+---------------------+        +---------------------+

The relevant types are:

  • AudioRenderers represent channels from applications that want to play audio.
  • AudioCapturers represent channels to applications that want to record audio.
  • AudioOutputs represent hardware outputs (speakers).
  • AudioInputs represent hardware inputs (microphones).

To control output routing, we use an enum called an AudioRenderUsage, which has values like BACKGROUND, MEDIA, COMMUNICATION, etc. We maintain a many-to-one mapping from AudioRenderUsage to AudioOutput, then map AudioRenderers to AudioOutputs based on this type. For example, if two AudioRenderers r1 and r2 are created with AudioRenderUsage MEDIA, they are both routed to the AudioOutput assigned to MEDIA (o2 in the above graph).

Input routing works similarly, using a type called AudioCaptureUsage. Additionally, special “loopback” inputs are routed from AudioOutputs.

Output Pipelines

At each AudioOutput, an OutputPipeline controls the mixing of input streams into a single output stream. This mixing happens in a graph structure that combines MixStage nodes (which mix multiple input streams into a single output) and EffectsStage nodes (which apply a sequence of transformations to an input stream). MixStage nodes also perform basic transformations: source format conversion, rechannelization, sample rate conversion, gain scaling, and accumulation. Gain scaling can be configured at both a per-stream level (per-AudioRenderer) and a per-AudioRenderUsage level (usually corresponding to volume controls on the device).

For example, the following graph illustrates an OutputPipeline created for four renderers, three of which (r1, r2, r3) are mixed first because they share the same AudioRenderUsage.

     r1  r2  r3
     |   |   |
  +--V---V---V---+
  |  m1  m2  m3  |
  |   MixStage   |
  +------|-------+
         |
  +------V-------+
  | EffectsStage |
  | 1. high pass |
  | 2. compress  |
  +---------\----+   r4
             \       |
           +--V------V---+
           |   m1    m2  |
           |   MixStage  |
           +------|------+
                  V
                device

If loopback capability is enabled for the given device, then a specific pipeline stage can be designated as the loopback stage. For example, if certain hardware-specific effects should not be included in the loopback stream, the loopback stream can be injected at an early stage before the final output is sent to the device.

Input Pipelines

There is no complex processing in AudioCapturers other than a simple mixer to merge multiple inputs.