How to compile alsa-utils in android
I recently looked at the ALSA driver and tried to compile the alsa-utils tool in android. The following describes how to compile and solve the problems encountered during the process:
First of all, I downloaded the alsa-utils-1.0.23 version of the tool from the ALSA official network, because my android alsa-lib is also version 1.023, to prevent different versions of the problem, I chose the same version, the path of our alsa-lib is under the android_source/external/alsa-lib directory, and the alsa-utils-1.023 toolkit we downloaded is also downloaded.
Next, we need to complete the following actions:
1. Create an Android. mk file under alsa-utils.
The written content is:
[Plain]
Ifeq ($ (strip $ (BOARD_USES_ALSA_AUDIO), true)
LOCAL_PATH: = $ (call my-dir)
#
# Build aplay command
#
Include $ (CLEAR_VARS)
LOCAL_CFLAGS: = \
-FPIC-D_POSIX_SOURCE \
-DALSA_CONFIG_DIR = \ "/system/usr/share/alsa \"\
-DALSA_PLUGIN_DIR = \ "/system/usr/lib/alsa-lib \"\
-DALSA_DEVICE_DIRECTORY = \ "/dev/snd /\"
LOCAL_C_INCLUDES: = \
$ (LOCAL_PATH)/include \
$ (LOCAL_PATH)/android \
External/alsa-lib/include
LOCAL_SRC_FILES: = \
Aplay/aplay. c
LOCAL_MODULE_TAGS: = debug
LOCAL_MODULE: = alsa_aplay
LOCAL_SHARED_LIBRARIES: = \
Libasound \
Libc
Include $ (BUILD_EXECUTABLE)
I wrote only the code for compiling the aplay tool above, and other tools write the same code.
2. Go to the alsa-utils toolkit and create the sys directory and aconfig. h file. Write the following content in aconfig. h file:
[Plain]
# Define DATADIR "/system/usr/share/alsa"
# Define rindex strrchr
# Define open64 open
# Undef _ swab16
# Define _ swab16 (x) _ arch _ swab16 (x ))
# Undef _ swab32
# Define _ swab32 (x) _ arch _ swab32 (x ))
3. Go to the sys directory created in step 1, create the signal. h header file in the sys directory, and write the following content in the header file:
[Plain]
# Include <signal. h>
4. Compile android directly. The following error may occur during the compilation process:
4.1: kernel/common/linux/un. h: 18: error: expected specifier-qualifier-list before 'sa _ family_t
That's because we didn't include # include <sys/socket. h> before include un. h In alsa-utils/alsactl/init_parse.c. You only need to include this header file before this.
4.2: this error may also occur: In aplay. in c, the system will prompt the error's _ IRGRP 'undeclared (first use in this function, as long as you are in aplay. add a header file in c: # include <sys/stat. h>. In this way, www.2cto.com is solved.
4.3: the next possible language to this error: the speaker-test.c reported wav_file_dir is not defined, this value is used to define the location of your wav file stored in pad, where you casually put, the path I defined is under the/sdcard directory.
After all the above modifications, the alsa-utils tool has finally been compiled successfully.