嵌入式 移植madplay到开发板
一、简述
记--编译madplay开源库,并移植到GEC6818开发板。
源码包+编译好的+mp3文件:链接: https://pan.baidu.com/s/1PRYPeH_Q2TvRFS4bZEPgHQ 提取码: ri92
二、下载相关源码
madplay 的移植需要以下几个库:zlib库、libid3tag库 、libmad库、 madplay库 。
zlib库源码下载:zlib Home Site
libid3tag库和libmad库源码下载:ftp://ftp.mars.org/pub/mpeg/
madplay库源码下载:MAD (MPEG Audio Decoder) - Browse /madplay at SourceForge.net
三、创建目录:mkdir madplayer (用来存放生成的madplay可执行文件和相关的库文件)
然后将zlib库、libid3tag库 、libmad库、 madplay库的源码包放到madplayer目录下:
四、编译zlib.a库
3.1 解压源码:tar -xJvf zlib-1.2.11.tar.xz
3.2 进入解压出来的目录:cd zlib-1.2.11/
3.3 检查、配置:./configure --prefix=/home/liang/madplayer
3.4 修改Makefile,设置交叉编译器工具。(注arm-linux-gcc是arm-none-linux-gnueabi的软连接)
将CC=gcc,改为CC=arm-linux-gcc (#号后面的是注释)
将AR=ar,改为AR=arm-linux-ar
将RANLIB=ranlib,改为RANLIB=arm-linux-ranlib
将LDSHARE=gcc ...修改为LDSHARE=arm-linux-gcc...;将CPP=gcc -E修改为CPP=arm-linux-gcc -E
3.5 编译:make
查看生成的库文件:
3.6 安装: make install
(安装好之后就可以在上面prefix 指定的目录下的lib 目录下找到libz.a这个库。)
四、编译libid3tag库
注:编译libid3tag库需要依赖zlib库,所以要在编译libid3tag库之前安装好zlib库。
4.1 解压源码包:tar -xzvf libid3tag-0.15.1b.tar.gz
4.2 进入到解压出来的文件目录:cd libid3tag-0.15.1b/
4.3 配置:
./configure --host=arm-linux CC=arm-linux-gcc --disable-debugging --disable-shared --enable-static --prefix=/home/liang/madplayer CPPFLAGS=-I/home/liang/madplayer/include LDFLAGS=-L/home/liang/madplayer/lib
配置完成:
可能出现错误:configure: error: C++ preprocessor "/lib/cpp" fails sanity check
原因是,没有安装从c++编译器,进行安装:sudo apt install g++
安装g++编译器成功:
4.4 编译:make
编译成功:
4.5 安装:make install
查看生成的库文件:
五、编译libmad库
5.1 解压源码包:tar -xzvf libmad-0.15.1b.tar.gz
5.2 进入解压出来的目录:cd libmad-0.15.1b/
5.3 检查、配置:
./configure --enable-fpm=arm --host=arm-linux --disable-debugging --disable-shared --enable-static --prefix=/home/liang/madplayer
配置成功:
5.4 修改Makefile。修改Makefile 129行,去掉-fforce-mem,gcc3.4或更高版本的编译器已经不支持该命令行。
查看当前的gcc版本:gcc -v , arm-none-linux-gnueabi-gcc -v
5.5 编译:make
编译成功:
5.6 安装:make install
查看生成的库文件:
六、编译madplay库
6.1 解压源码包:tar -xzvf madplay-0.15.2b.tar.gz
6.2 进入解压出来的目录: cd madplay-0.15.2b/
6.3 检查、配置,生成Makefiel:
./configure --host=arm-linux CC=arm-linux-gcc --disable-debugging --disable-shared --enable-static -prefix=/home/liang/madplayer ./configure --host=arm-linux CC=arm-linux-gcc --disable-debugging --disable-shared --enable-static -prefix=/home/liang/madplayer CPPFLAGS=-I/home/liang/madplayer/include LDFLAGS=-L/home/liang/madplayer/lib
配置成功:
6.4 编译:make
编译成功:
查看生成的madplayer可执行文件
七、传输到开发板上使用
播放mp3歌曲:
注:如果提示缺少xx.so等库文件,需要将相应的库文件拷贝到/lib下。
附:
madplay命令
# madplay --help
Usage: madplay [OPTIONS] FILE [...]
Decode and play MPEG audio FILE(s).
Verbosity:
-v, --verbose show status while decoding
-q, --quiet be quiet but show warnings
-Q, --very-quiet be quiet and do not show warnings
--display-time=MODE use default verbose time display MODE
(remaining, current, overall)
Decoding:
--downsample reduce sample rate 2:1
-i, --ignore-crc ignore CRC errors
--ancillary-output=PATH write ancillary data to PATH
Audio output:
-o, --output=[TYPE:]PATH write output to PATH with format TYPE (below)
-b, --bit-depth=DEPTH request DEPTH bits per sample
-R, --sample-rate=HERTZ request HERTZ samples per second
-d, --no-dither do not dither output PCM samples
--fade-in[=DURATION] fade-in songs over DURATION (default 0:05)
-a, --attenuate=DECIBELS attenuate signal by DECIBELS (-)
-a, --amplify=DECIBELS amplify signal by DECIBELS (+)
-A, --adjust-volume=DECIBELS override per-file volume adjustments
-G, --replay-gain[=PROFILE] enable Replay Gain volume adjustments using
PROFILE (radio, audiophile)
Channel selection:
-1, --left output first (left) channel only
-2, --right output second (right) channel only
-m, --mono mix left and right channels for monaural output
-S, --stereo force stereo output
Playback:
-s, --start=TIME skip to begin at TIME (HH:MM:SS.DDD)
-t, --time=DURATION play only for DURATION (HH:MM:SS.DDD)
-z, --shuffle randomize file list
-r, --repeat[=MAX] play files MAX times, or indefinitely
--tty-control enable keyboard controls
--no-tty-control disable keyboard controls
Miscellaneous:
-T, --show-tags-only show ID3/encoder tags only (do not decode)
-V, --version display version number and exit
--license show copyright/license message and exit
-h, --help display this help and exit
Supported output formats:
cdda CD audio, 16-bit big-endian 44100 Hz stereo PCM (*.cdr, *.cda)
aiff Audio IFF, [16-bit] PCM (*.aif, *.aiff)
wave Microsoft RIFF/WAVE, [16-bit] PCM (*.wav)
snd Sun/NeXT audio, 8-bit ISDN mu-law (*.au, *.snd)
raw binary [16-bit] host-endian linear PCM
hex ASCII hexadecimal [24-bit] linear PCM
null no output (decode only)
4.3 madplay快捷命令
p or SPACE pause movie (press any key to continue)
q or ESC stop playing and quit program
+ or - adjust audio delay by +/- 0.1 second
o cycle OSD mode: none / seekbar / seekbar + timer
* or / increase or decrease PCM volume