audio temporary summary

How to connect audioflinger to hal

1 audio_hw_hal.cpp: audio_hw_device This file shapes audio_hw_device

2
struct legacy_audio_device { struct audio_hw_device device; provided upwards

struct AudioHardwareInterface *hwif;  向下提供

};

3 The legacy_adev_open function in the audio_hw_hal.cpp file contains ladev->hwif = createAudioHardware();

4 The process of createAudioHardware
https://blog.csdn.net/syh63053767/article/details/9112153
From this function, you can connect to the class provided by the manufacturer (audiohardware)

5 Input and output interface adev_open_output_stream adev_open_input_stream
struct legacy_stream_out { struct audio_stream_out stream;

AudioStreamOut *legacy_out;

};

struct legacy_stream_in {
struct audio_stream_in stream;

AudioStreamIn *legacy_in;

}; The
above two interfaces are also connected through legacy_adev_open

6
AudioPolicyService startup process analysis
a. Load analysis /vendor/etc/audio_policy.conf or /system/etc/audio_policy.conf
For each module item in the configuration file, new HwModule(name), put it into the mHwModules array
. Each output, new IOProfile, put into the module's mOutputProfiles
For each input in the module, new IOProfile, put into the module's mInputProfiles
b. Load the so file provided by the manufacturer according to the name of the module (loaded by AudioFlinger)
c. Open the corresponding Output (open output through AudioFlinger)

profile: configuration, used to describe output

a. 本可以支持哪些设备

b. 参数: 采样率,通道

android audio summary
https://www.jianshu.com/p/5389a9abe2b9

7
DeviceVector mAvailableOutputDevices; // all available output devices
DeviceVector mAvailableInputDevices; // all available input devices
output devices, use mAvailableOutputDevices to maintain, mainly dealing with connection and disconnection. Handsets, Speakers and other devices that come with mobile phones are generally processed only when they are started, and do not need to be processed at other times. So the main thing is what we are talking about, Bluetooth headsets, wired headsets and so on.
Reference documents
Android Audio and earphones, Bluetooth earphones and other audio peripherals

8 After
moutputs
parses audio_policy.conf, traverse mHwModules[i]->mOutputProfiles, and then add it to mOutputs.
Refer to the
analysis of the Android audio output device selection process (on)

Guess you like

Origin blog.csdn.net/aningxiaoxixi/article/details/112455566