作者:武漢華嵌嵌入式培訓中心 講師 馮勇 一、s3c2410移植ALSA及相關工具使用 相關源碼文件 ncurses-5.6.tar.gz alsa-lib-1.0.17.tar.bz2 alsa-utils-1.0.17.tar.bz2 1. 設置環境變量 export MEDIA_INSTALL_DIR=/home/linux/driver/mplay/media_install 2. 編譯ncurses tar zxvf ncurses-5.6.tar.gz cd ncurses-5.6 ./configure --host=arm-linux --target=arm-linux --build=i686-linux --with-softfloat --prefix=/usr --without-ada CC=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc make make install DESTDIR=$MEDIA_INSTALL_DIR 2. 編譯alsa-lib tar jxvf alsa-lib-1.0.17.tar.bz2 cd alsa-lib-1.0.17 ./configure --host=arm-linux --target=arm-linux --build=i686-linux --with-softfloat --prefix=/usr --disable-python CC=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc 修改Makefile,刪除掉aserver和alsalisp所有部分(各2處 );因為運行configure設置了--with-softfloat ,不然會出錯。 make make install DESTDIR=$MEDIA_INSTALL_DIR 3.編譯alsa-util tar jxvf alsa-utils-1.0.17.tar.bz2 cd alsa-utils-1.0.17 ./configure --host=arm-linux --target=arm-linux --build=i686-linux --with-softfloat --prefix=/usr --with-alsa-prefix=$MEDIA_INSTALL_DIR/usr/lib --with-alsa-inc-prefix=$MEDIA_INSTALL_DIR/usr/include CC=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc make make install DESTDIR=$MEDIA_INSTALL_DIR 4.相關工具使用 (1) 由于alsa util工具訪問音頻alsa設備目錄在/dev/snd下,可先創建一個腳本:create_snd_dev.sh mkdir /dev/snd ln -s /dev/controlC0 /dev/snd/controlC0 ln -s /dev/pcmC0D0c /dev/snd/pcmC0D0c ln -s /dev/pcmC0D0p /dev/snd/pcmC0D0p ln -s /dev/mixer /dev/snd/mixer ln -s /dev/timer /dev/snd/timer (2) 使用aplay直接播放wav文件 ./aplay xxx.wav 二、s3c2410上mp3庫及madplay移植 相關源碼文件 zlib-1.2.3.tar.gz libid3tag-0.15.1b.tar.gz libmad-0.15.1b.tar.gz madplay-0.15.2b.tar.gz 1.編譯zlib-1.2.3 tar zxvf zlib-1.2.3.tar.gz cd zlib-1.2.3 ./configure --prefix=/home/linux/driver/mplay/media_install/usr 修改Makefile CC=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc AR=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-ar rc RANLIB=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-ranlib make make install 2. 編譯libid3tag tar zxvf libid3tag-0.15.1b.tar.gz cd libid3tag-0.15.1b ./configure --prefix=/home/linux/driver/mplay/media_install/usr --host=arm-linux --disable-debugging CC=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc CPPFLAGS="-I/home/linux/driver/mplay/media_install/usr/include" LDFLAGS="-L/home/linux/driver/mplay/media_install/usr/lib" make make install 3. 編譯libmad tar zxvf libmad-0.15.1b.tar.gz cd libmad-0.15.1b ./configure --prefix=/home/linux/driver/mplay/media_install/usr --host=arm-linux --disable-debugging CC=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc CPPFLAGS="-I/home/linux/driver/mplay/media_install/usr/include" LDFLAGS="-L/home/linux/driver/mplay/media_install/usr/lib" make 出現:cc1: error: unrecognized command line option "-fforce-mem" 修改Makefile 在Makefile中找到包含"fforce-mem"字符串,將其刪除即可;原因:gcc3.4或更高版本中,已將將該選項去除了。 再重新make即可 make install 4. 編譯madplay tar zxvf madplay-0.15.2b.tar.gz cd madplay-0.15.2b ./configure --prefix=/home/linux/driver/mplay/media_install/usr --host=arm-linux --disable-debugging --with-alsa CC=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc CPPFLAGS="-I/home/linux/driver/mplay/media_install/usr/include" LDFLAGS="-L/home/linux/driver/mplay/media_install/usr/lib" make 編譯出錯: /opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc -Wall -O2 -fomit-frame-pointer -o madplay madplay.o getopt.o getopt1.o version.o resample.o filter.o tag.o crc.o rgain.o player.o audio.o audio_aiff.o audio_cdda.o audio_hex.o audio_null.o audio_raw.o audio_snd.o audio_wave.o audio_alsa.o -L/media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib /usr/lib/libasound.so -ldl -lpthread -lrt /media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib/libmad.so /media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib/libid3tag.so -lz -lm -Wl,--rpath -Wl,/media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib -Wl,--rpath -Wl,/media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib 直接修改最后一步: /opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc -Wall -O2 -fomit-frame-pointer -o madplay madplay.o getopt.o getopt1.o version.o resample.o filter.o tag.o crc.o rgain.o player.o audio.o audio_aiff.o audio_cdda.o audio_hex.o audio_null.o audio_raw.o audio_snd.o audio_wave.o audio_alsa.o -L/media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib /media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib/libasound.so -ldl -lpthread -lrt /media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib/libmad.so /media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib/libid3tag.so -lz -lm -Wl,--rpath -Wl,/media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib -Wl,--rpath -Wl,/media/LinuxWorks/p760/multimedia/myworks/media_install/usr/lib make install 5.相關工具使用 ./madplay tears.mp3 三、MPlayer在s3c2410上移植(軟解碼) tar jxvf MPlayer-1.0rc2.tar.bz2 cd MPlayer-1.0rc2 ./configure --cc=/opt/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-gcc --host-cc=gcc --target=armv4l-linux --prefix=/home/linux/driver/mplay/media_install/usr --disable-w32threads --disable-dvdread --disable-mencoder --disable-live --disable-mp3lib --disable-tv --disable-tv-v4l1 --disable-tv-v4l2 --disable-tv-bsdbt848 --disable-radio-v4l2 --disable-dvdnav --disable-cdparanoia --disable-bitmap-font --disable-ftp --disable-vstream --disable-ass --disable-network --enable-xv --enable-mad --enable-alsa --with-extraincdir=/home/linux/driver/mplay/media_install/usr/include --with-extralibdir=/home/linux/driver/mplay/media_install/usr/lib make 在目錄中就會生成mplayer可執行文件 mplayer軟件對mpeg4解碼還比較流暢;但H264的格式解碼性能不夠,音視頻會不同步。 mplayer tears.mp3 //可以播放mp3文件 mplayer HarryPotter.avi //MPEG4格式480 x 272格式 |