From: http://book.51cto.com/art/201001/179672.htm
Chapter 2Android audio system
This chapter introduces the content of the android audio system, which is mainly the audio input/output link and does not involve codec content (the audio system has content from the driver, local framework to Java framework ). This chapter describes the content at each level of the audio system and the implementation of the audio hardware abstraction layer.
When studying this chapter, you should pay attention to the following:
Audio System Structure (knowledge content)
How to call the audio system in Java (knowledge content)
Audio System local code interface (Development points)
Implementation of the audio Hardware Abstraction Layer (Development points)
7.1 Audio System Overview
The audio system is responsible for audio data stream transmission and control in Android, and also for audio device management. This part serves as the input/output level of the android audio system. It is generally responsible for playing PCM sound output and obtaining PCM sound from the outside, as well as managing sound devices and settings.
The audio system is divided into the following layers:
(1) local audio system interfaces provided by the media library;
(2) audioflinger serves as the middle layer of the audio system;
(3) The hardware abstraction layer of audio provides underlying support;
(4) The audio interface is provided to the upper layer through the JNI and Java frameworks.
The APIs of the audio system provide two functions: Sound Recording and recorder ).
The android audio system structure is 7-1.
Figure 7-1 Android Audio System Structure
The code distribution of the Android system is as follows:
(1) Java section of audio
Code path: Frameworks/base/Media/Java/Android/Media
The Java package related to audio is Android. Media, which mainly includes several classes of audiomanager and audio systems.
(2) JNI section of audio
Code path: Frameworks/base/CORE/JNI
Generate the libandroid_runtime.so library. The JNI of audio is a part of it.
(3) Framework of audio
Header file path: Frameworks/base/include/Media/
Source code path: Frameworks/base/Media/libmedia/
The local audio framework is part of the media library. This part of content is compiled into the library libmedia. So, which provides APIs for the audio part (including the binder-based IPC Mechanism ).
(4) Audio flinger
Code path: Frameworks/base/libs/audioflinger
This part of content is compiled into the library libaudioflinger. So, which is the local service part of the audio system.
(5) Hardware Abstraction Layer interface of audio
Header file path: Hardware/libhardware_legacy/include/hardware/
The implementation of the audio hardware abstraction layer may be different in various systems. You need to use the code to inherit the corresponding classes and implement them as the local framework layer and driver interface of the Android system.