First understanding of Android audio framework

tags: Android underlying development  android  framework  Android audio subsystem

Overview

Audio audio subsystem is one of the important subsystems of the Android Framework and one of the most complex subsystems. It is responsible for the audio data streaming and control functions in Android, as well as the management of audio equipment. A complete Android audio system architecture is shown below:

audio frame layering

application layer

Application layer, call the app or settings of audio service, such as: audio and video player, making phone calls, recording/video recording, volume setting, etc.

Framework layer

The Framework layer includes java and c++, and calls each other through the jni mechanism. It is mainly divided into the following three layers:

Framework java

Framework java layer provides java interface called by APP. The code location of this layer is **[frameworks/base/media/java/android/media]**, which mainly includes:

  • MediaPlayer.java: Provide an interface called by the playing APP, supporting audio files in various formats;
  • MediaRecorder.java: Provide an interface for calling audio recording APP;
  • AudioTrack.java: Provide an interface called by the audio playback APP, this can only be used to play audio files in wav format;
  • AudioRecorder.java: Responsible for the collection of recording data, belonging to the Android application framework API class;
  • AudioManager.java: provides sound control;
  • AudioService.java: channel selection;
  • AudioSystem: sound effect settings;
    Among them, MediaPlayer and MediaRecorder have similar functions compared to AudioTrack and AudioRecorder. They are powerful and easy to use, but they are highly packaged and not suitable for in-depth development.

jni

The Audio JNI layer is a bridge between the audio application framework and the local framework. The C++ layer code can be called through the JNI layer. It is equivalent to a bridge that makes the java function interface and the c++ function interface one-to-one correspondence. The corresponding directory is **[framewoks/ base/core/jni and frameworks/base/core/jni】**

  • android_media_MediaPlayer.cpp
  • android_media_AudioRecord.cpp
  • android_media_AudioTrack.cpp
  • android_media_AudioSystem.cpp

Native Framework

Native Framework is written in C++ language, and is called by the Framework java layer through jni conversion. It is divided into client and server parts, which correspond to the playback, recording interface, sound control, and settings in the Framework java layer.
Client:【frameworks/av/media/libaudioclient】

  • AudioRecord.cpp: Responsible for the collection of recording data, belonging to the Android native framework API class
  • AudioTrack.cpp: Responsible for the output of playback data, belonging to the Android native framework API class;
  • AudioSystem.cpp: Responsible for the comprehensive management of audio affairs, belonging to the Android native framework API class

Server: [Frameworks/av/services/audioflinger] compiled into libaudioflinger library, running in AudioServer system process

  • AudioFlinger.cpp
  • AudioHwDevice.cpp
  • AudioStreamOut.cpp

HAL layer

The HAL layer is the object that AudioFlinger accesses downwards. The manufacturer will implement its own interface layer at this layer, bridge the hardware driver and the upper framework, and the formed file will be compiled into audio.primary., audio.a2dp. and other so library files for audio Module loading.

  • HAL interface layer: [hardware/interfaces/audio]
  • HAL implementation layer: [hardware/libhardware/modules/audio]

Specific call process

Intelligent Recommendation

Understanding the ALSA Audio Framework: Foreword

ALSA is the abbreviation of Advanced Linux Sound Architecture, and is a driver framework for linux sound cards. OSS is similar. In short, the sound card is a piece of external hardware used for playba...

ALSA audio framework understanding: machine

In the previous section, we mentioned that ASoC is divided into three parts: Machine, Platform, and Codec. The Machine driver is responsible for the coupling between Platform and Codec, as well as par...

Sound: Audio framework for Android audio system

Audio framework for Android audio system April 13, 2013 11:58:12Lin Xuesen Reading number: 36305More Personal classification:Android column Column:Thinking In Android 1.1 Audio Framework Reprint, plea...

android audio/linux alsa audio-framework

The audio part has always been one of the difficulties in linux/android development. The audio system used in the early days of LINUX is OSS (Open Sound System). For various reasons (you can GOOGLE), ...

The first understanding of the ConnectivityService framework

There are several types of data services provided in Android: mobile data networks, WIFI, hotspots, network cables, and so on. These data services can be used independently, but at the same time, only...

More Recommendation

First understanding of Vue framework

As we all know, Vue is a front-end framework. Then the first question arises, what is a framework? Framework refers to a set of excellent code that can be used repeatedly (software semi-finished produ...

The first understanding of nimi_web framework

Recently, the blogger has moved, but it hasn't changed in a few days. Now I will share with you a very small framework, mini_web, and tell you what it means. The idea is not difficult, first analyze t...

First understanding of Gin framework

Specific instructions and source code about Gin:https://github.com/gin-gonic/gin 1. Installation Command line input:go get github.com/gin-gonic/gin Installation location: the global lib directory conf...

First understanding of yii2 framework

Architecture Workflow Controller rule: The first letter of the controller file name is capitalized and ends with Controller The controller class must inherit the Controller class, use yii\web\Controll...

Android audio framework notes - next

Remind, pure personal notes, you may see dizzy Sixth, HAL layer 6-1, Audio HAL layer, in fact, including audio.xxx.so and audiopolicy.so. From the above-mentioned general framework diagram, there are ...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top