The overall android audio includes the android layer and the underlying ASLA driver.
Recently, I started to call the 3G Function and then began to access the android audio architecture. I had some experience debugging the sound card before. However, these functions are relatively simple and basically only need to modify the audio path, that is, modify audio_codec.h, which defines the audio data flow in various circumstances. A struct is defined as follows:
Typedef struct AudioMixer_tag {
Const char * ctl;
Const int val;
} AudioMixer;
The specific definition format is as follows:
Onst AudioMixer device_out_SPK [] = {// playback_speaker // path {"AIF1DACL Source", 0}, // Left DAC receive left channel {"AIF1DACR Source", 1 }, // Right DAC receive right channel {"AIF1DAC Mux", 0}, // AIF1DAC, select AIF1DACDAT {"DAC1L Mixer AIF1.1 Switch", 1 }, // AIF1DAC1L --> DAC1L Mixer {"DAC1R Mixer AIF1.1 Switch", 1}, // AIF1DAC1R --> DAC1R Mixer {"SPKL DAC1 Switch", 1 }, // DAC1L --> SPKL {"SPKR DAC 1 Switch ", 1}, // DAC1R --> SPKR {" SPKL Boost SPKL Switch ", 1}, // SPKL --> SPKL Boost {" SPKR Boost SPKR Switch ", 1}, // SPKR --> SPKR Bootst // gain {"Headphone Switch", 0}, // hpout pga mute {"Speaker Mode", 0 }, // Class D {"Speaker ZC Switch", 0}, // disable ZC {"Speaker Volume", 60}, // SPK volume, + 3 dB {"Speaker Boost Volume", 4}, // 2.0x boost, + 6.0dB {"Speaker Mixer Volume", 3}, // SPK Mixer Volume 0d B {"Speaker Switch", 1}, // SPK OUTPUT PGA unmute {"DAC1 Volume", 96}, // DAC1 Volume, 0dB {"DAC1 Switch", 1 }, // DAC1 Switch, unmute {"AIF1DAC1 Volume", 96}, // AIF1DAC1 Input Volume, 0dB {NULL, 0}; 3G speech can be divided into two types, one is analog speech and the other is PCM Digital Speech. Different speech data are used, and the hardware circuit is different.
Analog speech is relatively simple. MIC and SPEAKER devices can be directly connected to 3G modules, or analog output can be connected to sound card devices for more precise management. If PCM Digital Speech is used, the PCM Interface of the sound card device or CPU must support slave mode. At the beginning, the debugging thought that the analog audio was relatively simple. This method was used for debugging, but it was found that the volume adjustment was a problem after the adjustment, and the audio data could not be controlled without going through the CPU. After analyzing the android audio flow code, we found that the android audio volume adjustment does not involve hardware and is completely implemented through mixer. About android volume adjustment can refer to the article "android volume settings from top to bottom": http://blog.csdn.net/kld2009/article/details/8865680, this brother wrote in detail.
To adjust the volume, you must adjust the volume output of the 3G module by hardware. Later, I tried this method. However, I found that the effect was not very good. I found that the response was delayed when adjusting the volume on the setting interface, A possible method or code problem is to read and write a file at the bottom layer where java adjusts the volume. The bottom layer reads and writes 3G module registers to adjust the volume according to file changes.
When looking at the audio hal layer code, we found that Samsung adjusted the volume not through the above two methods, but through the SECRILD library file, as shown below:
OpenClientRILD = (HRilClient (*) (void ))
Dlsym (mSecRilLibHandle, "OpenClient_RILD ");
DisconnectRILD = (int (*) (HRilClient ))
Dlsym (mSecRilLibHandle, "Disconnect_RILD ");
CloseClientRILD = (int (*) (HRilClient ))
Dlsym (mSecRilLibHandle, "CloseClient_RILD ");
IsConnectedRILD = (int (*) (HRilClient ))
Dlsym (mSecRilLibHandle, "isConnected_RILD ");
ConnectRILD = (int (*) (HRilClient ))
Dlsym (mSecRilLibHandle, "Connect_RILD ");
SetCallVolume = (int (*) (HRilClient, SoundType, int ))
Dlsym (mSecRilLibHandle, "SetCallVolume ");
SetCallAudioPath = (int (*) (HRilClient, AudioPath ))
Dlsym (mSecRilLibHandle, "SetCallAudioPath ");
SetCallClockSync = (int (*) (HRilClient, SoundClockCondition ))
Dlsym (mSecRilLibHandle, "SetCallClockSync ");
By calling these settings to adjust the Voice settings of the 3G module, it should be implemented through the AT command, but it is still unclear if the source code is not implemented.