One of the accumulation of Android audio architecture on the Samsung platform

Source: Internet
Author: User

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 dac1 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 0db
{
"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
} };

There are two types of 3G speech: analog speech and PCM Digital Speech. Different types of Speech data have different hardware circuits.

 

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 processCodeIt is found that android's volume adjustment does not involve hardware and is completely implemented through mixer. For details about how to adjust the android volume, referArticle"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.

-------------------------------- To be continued --------------------------------------

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.