0% found this document useful (0 votes)
323 views19 pages

Android Audio System

The document discusses the Android audio system architecture which includes the audio framework, audio HAL, and audio driver. The audio framework consists of AudioTrack, AudioRecord, AudioPolicy and AudioFlinger which control audio routing and playback. AudioPolicy decides which AudioFlinger thread handles which audio stream. AudioFlinger contains multiple threads that read and write audio data. The audio HAL provides an interface between the audio framework and low-level audio driver. It handles functions like audio device opening, reading, writing and controls like volume. The audio driver interacts with the hardware and ALSA for low-level audio playback and capture.

Uploaded by

Suresh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
323 views19 pages

Android Audio System

The document discusses the Android audio system architecture which includes the audio framework, audio HAL, and audio driver. The audio framework consists of AudioTrack, AudioRecord, AudioPolicy and AudioFlinger which control audio routing and playback. AudioPolicy decides which AudioFlinger thread handles which audio stream. AudioFlinger contains multiple threads that read and write audio data. The audio HAL provides an interface between the audio framework and low-level audio driver. It handles functions like audio device opening, reading, writing and controls like volume. The audio driver interacts with the hardware and ALSA for low-level audio playback and capture.

Uploaded by

Suresh Kumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Android Audio System

Introduction
Outline
• Background
• Android Audio System
• Audio Framework
• Audio HAL

2
Background
3
Background
• Information about this slide
• Software
• Android 4.0/4.2

4
Android Audio System
5
Architecture Audio System
• The complexity of android audio system
• Soft real-time requirement
• Large number of usage scenarios
• Software
• phone/media player/…
• different volume setting/…
• Hardware
• earpiece/speaker/hdmi/…
• mic/bluetooth/…
• Flexibility design
• good design pattern
• performance (Java/JNI/binder/…)
6
Architecture Audio System
Java App

Android Framework

Audio HAL

Linux Driver

7
Android Audio System
pcm data
app

data flow
control flow Audio Audio
AudioTrack/AudioRecord/… Policy Flinger
(AudioPolicy/AudioFlinger/…)

Audio HAL
(open/read/write/…)

Audio Driver
8
Audio Framework
9
Audio Framework
Network Packet Routing

sender 1 router
receiver 1
sender 2
Routing path receiver 2
sender 3
receiver 3
sender 4

10
Audio Framework
Audio Routing (play audio)

AudioTrack 1 Audio
Policy Hardware 1
AudioTrack 2
Audio Flinger Hardware 2
AudioTrack 3

Hardware 3
AudioTrack 4

Java App Audio Framework 11


Audio HAL
Audio Policy
• Decide which thread in AudioFlinger should sound be
attached.
• stream  strategy  output
• stream : VOICE_CALL, TTS, MUSIC, …
• strategy : PHONE, MUSIC, …
• output : a thread in AudioFlinger
• strategy : bridge between software data stream and hardware

12
Audio Policy

13
Audio Policy
• IOProfile (audio_policy.conf)
• Content
• Define all the possible I/O devices
• Define default I/O device
• Hierarchical structure
• hardware module
• profile
• sampling_rates/channels/formats/devices/flags
• With IOProfile, audio policy gets better OO structure.

14
Audio Policy

15
Audio Flinger
• Several thread to read/write data
• Create thread by AudioPolicy
• mixer thread
• duplicating thread
• direct output thread
• Resampler
• Non-blocking audio I/O
• AudioWatchdog

16
Audio HAL
17
Audio HAL
app

AudioTrack/AudioRecord/…
(AudioPolicy/AudioFlinger/…)

Audio HAL
(open/read/write/…)

Audio Driver
18
Audio HAL
• ALSA (Advanced Linux Sound Architecture)
• unified interface/SMP/thread-safe/…
• usespace library
• alsa-lib
• tinyalsa
• tinyplay/tinycap/ tinymix

• Audio HAL interface


• volume setting
• I/O function
• …
19

You might also like