Underlying debugging of Android audio-Based on tinyalsa and androidtinyalsa
By default, standard alsa is not used in Android, but tinyalsa is used. Therefore, libtinyalsa is used for command line-based testing. The Android system can view these tools in real time when the upper-layer Audio is ever changing, such as switching the Audio channel.
1. Compile the tinyalsa Tool
$ Mmm external/tinyalsa/
After compilation, tinyplay, tinymix, tinycap, and other tools will be generated.
Tinymix: View configuration Mixer
Tinyplay: play audio
Tinycap: Recording
2. view the sound card of the current system
root@android:/ # cat /proc/asound/cards 0 [RKRK616 ]: RK_RK616 - RK_RK616 RK_RK616 1 [ROCKCHIPSPDIF ]: ROCKCHIP-SPDIF - ROCKCHIP-SPDIF ROCKCHIP-SPDIFroot@android:/ #
3. tinymix
Tinymix usage method a. Without any parameters-display the current configuration B. tinymix [ctrl id] [var] without [var]. You can view the [ctrl id] Option.
root@android:/ # tinymixNumber of controls: 7ctltypenumname value0ENUM1Playback Path OFF1ENUM1Capture MIC Path MIC OFF2ENUM1Voice Call Path OFF3ENUM1Voip Path OFF4INT2Speaker Playback Volume 0 05INT2Headphone Playback Volume 0 06ENUM1Modem Input Enable ONroot@android:/ #
Explanation:
English |
Chinese |
Remarks |
Playback Path |
Audio output channel |
|
Capture MIC Path |
Audio input channel |
|
Voice Call APIs |
Call audio channel |
Unable to test because the device does not have a call module |
Voip APIs |
IP telephone audio channel |
Scenario Gtalk; values: SPK/HP_NO_MIC/BT |
Speaker Playback Volume |
Speaker volume |
It is irrelevant to the upper volume. |
Headphone Playback Volume |
Earphone volume |
Same as above |
Modem Input Enable |
I do not know how to use it |
Tested, audio input and output cannot be controlled. |
|
|
|
Playback Path:
English |
Chinese |
Remarks |
OFF |
Close |
|
RCV |
- |
|
SPK |
Speaker |
Common |
HP |
Ear belt microphone |
|
HP_NO_MIC |
Headset without microphone |
Common |
BT |
Bluetooth |
|
SPK_HP |
- |
|
RING_SPK |
- |
|
RING_HP |
- |
|
RING_HP_NO_MIC |
- |
|
RING_SPK_HP |
- |
|
For example, switch the output to the speaker.
Root @ android:/# tinymix 0 SPK
Summary of tinymix:
It is observed that the Android system does not directly use tinyalsa to adjust the sound volume, but is implemented based on the upper-layer software because no matter how the upper-layer volume changes, here we see 24 (taking the device I used as an example ). Channel switching is actually using tinyalsa. When playing music through different channels, you can observe the channel switching in real time. On a website, we can see that Android will talk about alsa 3 seconds after there is no sound playing. It is also confirmed that I used to think that the Android system will occupy the audio device permanently.
When playing music through Bluetooth, it is no longer through alsa. Tinymix can be viewed in a closed state, because all the Bluetooth protocols of Android4.2 are implemented at the user layer, and the uart channel is used directly. This design will be incomprehensible at half past one.
4. Use tinyplay to play wav music
This is just the most basic player, so it does not support playing MP3 and other compressed formats of music. Before I learned how to use it, I said it was very troublesome on the Internet, but now it seems that it is not troublesome to play the 44.1 kHz/44.8kHz wav music directly.
root@android:/ # tinyplay /sdcard/0_16.wav Playing sample: 2 ch, 44100 hz, 16 bitroot@android:/ #
Note: Before playing a video, you must first set the channel using tinymix. An example has been provided in the previous article to set the channel to the speaker. Since the maximum volume used for playing a video, so be sure to avoid being scared. Upload the audio file.
5. tinycap usage
Root @ android:/# tinycap/sdcard/test.wav
Recording is supported.
If you only encounter these problems at present, we can summarize them first, so that you can go deeper at any time.
Other assumptions confirmed as false:
1. init. rc needs to be rewritten so that the system does not start android-related services (mediaserver)
2. tinyalsa needs to be obtained through other channels.
Android underlying development problems?
Android underlying layer?
Do you mean android platform code development or development of android scripts and version control?
For android platform code development:
Download the source code from the google website and study the underlying Java basics.
If you want to develop scripts, version control, or C code at the bottom of android:
Then you need to be very familiar with C and have a good understanding of the android source code structure, and you need to understand JNI and other technologies.
I wrote an android underlying driver. How can I debug it?
There are two types: one is the driver implemented in the kernel, which is no different from the general linux kernel driver, and there is nothing special about debugging, such as printk plus printing and debug fs. Another kind of driver is implemented at the Hal layer, and it is also a log, maybe debug fs is not used