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

19
Android Audio System Introduction

Transcript of Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL...

Page 1: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Android Audio System Introduction

Page 2: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

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

2

Page 3: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Background

3

Page 4: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Background• Information about this slide

• Software• Android 4.0/4.2

4

Page 5: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Android Audio System

5

Page 6: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

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

Page 7: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Architecture Audio System

7

Linux Driver

Audio HAL

Android Framework

Java App

Page 8: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Android Audio System

8

app

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

Audio HAL(open/read/write/…)

Audio Driver

control flow data flow

pcm data

Audio Policy

Audio Flinger

Page 9: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Audio Framework

9

Page 10: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Audio Framework

10

routerreceiver 1

sender 1

Network Packet Routing

sender 2

sender 3

sender 4

receiver 2

receiver 3

Routing path

Page 11: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Audio Framework

11

Audio Policy Hardware 1

AudioTrack 1

Audio Routing (play audio)

Hardware 2

Hardware 3

Audio FlingerAudioTrack 2

AudioTrack 3

AudioTrack 4

Java App Audio FrameworkAudio HAL

Page 12: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

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

Page 13: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Audio Policy

13

Page 14: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

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

Page 15: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Audio Policy

15

Page 16: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

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

Page 17: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Audio HAL

17

Page 18: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

Audio HAL

Platform Group

18

app

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

Audio HAL(open/read/write/…)

Audio Driver

Page 19: Android Audio System Introduction. Outline Background Android Audio System Audio Framework Audio HAL 2.

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