搞过系统的人应该知道framework和driver之间有一层lib,下面就讲一下音频框架中对应的lib库和一些工具alsa-lib&alsa-utils。
alsa-lib for arm:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/bash
echo "Building alsa library for arm platform..."
# building shared library
CC=arm-linux-gnueabihf-gcc ./configure --host=arm-linux-gnueabi --target=arm-linux --prefix=/home/larkin/audio/alsa-lib/out/arm/alsa-lib/ --with-alsa-devdir=/dev/snd --enable-static=no --enable-shared=yes --disable-python --with-configdir=/home/larkin/audio/alsa-lib/out/arm/alsa-config --with-plugindir=/home/larkin/audio/alsa-lib/out/arm/alsa-plugin CFLAGS="-fPIC";
if [ $? -ne 0 ]; then
echo "Configure alsa-lib shared library failed..."
exit 1
fi
make clean; make;
if [ $? -ne 0 ]; then
echo "Build shared alsa-lib failed..."
exit 2
fi
make install;
# building static library
CC=arm-linux-gnueabihf-gcc ./configure --host=arm-linux-gnueabi --target=arm-linux --prefix=/home/linux/workplace/share/tmp/alsa-lib --with-alsa-devdir=/dev/snd --enable-static=yes --enable-shared=no --disable-python --with-configdir=/home/linux/workplace/share/tmp/alsa-config --with-plugindir=/home/linux/workplace/share/tmp/alsa-plugin;
if [ $? -ne 0 ]; then
echo "Configure alsa-lib static library failed..."
exit 3
fi
make clean; make;
if [ $? -ne 0 ]; then
echo "Build static alsa-lib failed..."
exit 4
fi
make install;
echo "The arm alsa-lib build process is finished successfully."
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
alsa-lib for pc:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
#!/bin/bash
echo "Building alsa library for x86 platform..."
# building shared library
CC=gcc ./configure --prefix=/home/larkin/audio/alsa-lib/out/pc/alsa-lib/ --with-alsa-devdir=/dev/snd --enable-static=no --enable-shared=yes --disable-python --with-configdir=/home/larkin/audio/alsa-lib/out/pc/alsa-config --with-plugindir=/home/larkin/audio/alsa-lib/out/pc/alsa-plugin CFLAGS="-fPIC";
if [ $? -ne 0 ]; then
echo "Configure alsa-lib shared library failed..."
exit 1
fi
make clean; make;
if [ $? -ne 0 ]; then
echo "Build shared alsa-lib failed..."
exit 2
fi
make install;
# building static library
CC=gcc ./configure --prefix=/home/larkin/audio/alsa-lib/out/pc/alsa-lib/ --with-alsa-devdir=/dev/snd --enable-static=yes --enable-shared=no --disable-python --with-configdir=/home/larkin/audio/alsa-lib/out/pc/alsa-config --with-plugindir=/home/larkin/audio/alsa-lib/out/pc/alsa-plugin;
if [ $? -ne 0 ]; then
echo "Configure alsa-lib static library failed..."
exit 3
fi
make clean; make;
if [ $? -ne 0 ]; then
echo "Build static alsa-lib failed..."
exit 4
fi
make install;
cd ./test;
# build alsa-lib pcm test code
gcc pcm_min.c -I/home/larkin/audio/alsa-lib/out/pc/alsa-lib/include/ -L/home/huangc/audio/alsa-lib/out/pc/alsa-lib/lib/ -lasound -lpthread -lrt -lm -ldl -o pcm_min;
if [ $? -ne 0 ]; then
echo "Build pcm_min.c failed..."
exit 5
fi
gcc pcm.c -I/home/larkin/audio/alsa-lib/out/pc/alsa-lib/include/ -L/home/huangc/audio/alsa-lib/out/pc/alsa-lib/lib/ -lasound -lpthread -lrt -lm -ldl -o pcm;
if [ $? -ne 0 ]; then
echo "Build pcm.c failed..."
exit 5
fi
# list the output files
ls -l pcm pcm_min ../out/pc/alsa-lib/lib/*;
cd ..;
echo "The x86 alsa-lib build process is finished successfully."
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
alsa-utils:
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
/* alsa-utils build for arm platform*/
CC=arm-linux-gnueabihf-gcc ./configure --host=arm-linux-gnueabihf --target=arm-linux --prefix=/home/linux/workplace/share/foxp/ CFLAGS="-I/home/linux/workplace/share/tmp/alsa-lib/out/arm/alsa-lib/include -lpthread -fPIC" LDFLAGS="-L/home/linux/workplace/share/tmp/alsa-lib/out/arm/alsa-lib/lib" LIBS="-lasound" --disable-alsamixer --disable-xmlto; make clean; make; sudo make install;
/* alsa-utils aplay */
root@:/home/larkin/alsa/alsa-utils/amixer# arm-linux-gnueabihf-gcc aplay.c -I/home/larkin/alsa/alsa-lib/build/include -I/home/larkin/alsa/alsa-utils/include -L/home/larkin/alsa/alsa-lib/build/lib -lasound -lrt -ldl -lm -lpthread -static -o aplays
/* alsa-utils amixer */
root@:/home/larkin/alsa/alsa-lib/build/share/alsa# arm-linux-gnueabihf-gcc amixer.c volume_mapping.c -I/home/larkin/alsa/alsa-lib/build/include -I/home/larkin/alsa/alsa-utils/include -L/home/larkin/alsa/alsa-lib/build/lib -lasound -lrt -ldl -lm -lpthread -static -o amixers
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>