linux mp3移植

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/yueqian_scut/article/details/82966504

       ubuntu系统的apt-get install安装sox会解决库依赖的问题,但是如果嵌入式系统本身没有网络设备,则需要手动安装各种库,并且需要解决依赖的问题。现将ubuntu系统移植mp3解码和播放的过程列出:

1. zlib-1.2.3

    zlib为id3格式解析库所依赖。

    1)tar -zxvf zlib-1.2.3.tar.gz

    2) ./configure --prefix=ZLIB_DIRECTORY (库安装目录) --disable-debugging --disable-shared --enable-static

    3)make & make install

2. libid3tag-0.15.1b

    mp3文件格式解析库    

    1)tar -zxvf libid3tag-0.15.1b.tar.gz

    2) ./configure --prefix=ID3_DIRECTORY (库安装目录,需绝对目录) --disable-debugging --disable-shared --enable-static

    3)make & make install

3. libmad-0.15.1b

    mp3解码库    

   1)tar -zxvf libmad-0.15.1b.tar.gz

    2) ./configure --prefix=ID3_DIRECTORY (库安装目录,需绝对目录) --disable-debugging --disable-shared --enable-static

    3)make & make install

如编译出错有提示“--fforce-mem”,则删除Makefile里面出现的"-fforce-mem"

如出现“ does not support Thumb mode `rsc r0,r0,#0'”,则修改fixed.h文件,将

#  define MAD_F_MLN(hi, lo)  \
    asm ("rsbs  %0, %2, #0\n\t"  \
         "rsc   %1, %3, #0"  \
         : "=r" (lo), "=r" (hi)  \
         : "0" (lo), "1" (hi)  \
         : "cc")

改为

#ifdef __thumb__
/* In Thumb-2, the RSB-immediate instruction is only allowed with a zero
operand. If needed this code can also support Thumb-1 
(simply append "s" to the end of the second two instructions). */
# define MAD_F_MLN(hi, lo) \
asm ("rsbs %0, %0, #0\n\t" \
"       sbc %1, %1, %1\n\t" \
        "sub %1, %1, %2" \
        : "+&r" (lo), "=&r" (hi) \
        : "r" (hi) \
        : "cc")
#else /* ! __thumb__ */
# define MAD_F_MLN(hi, lo) \
        asm ("rsbs %0, %2, #0\n\t" \
        "rsc %1, %3, #0" \
         : "=r" (lo), "=r" (hi) \
          : "=&r" (lo), "=r" (hi) \
          : "0" (lo), "1" (hi) \
          : "cc")
#endif /* __thumb__ */

4. alsa-lib-1.1.6

    声卡驱动,并提供上层音频应用调用接口,如下面的sox    

    1)tar -jxvf alsa-lib-1.1.6.tar.gz2

    2) ./configure --prefix=ID3_DIRECTORY (库安装目录,需绝对目录) --disable-debugging --disable-shared --enable-static

    3)make & make install

5. sox-14.4.1.tar.gz

    音频工具箱,播放和录制应用程序,其播放play程序会调用mad解码库进行解码,并把解码数据送到alsa库去播放。

   1)tar -zxvf sox-14.4.1.tar.gz

    2) ./configure --prefix=ID3_DIRECTORY (库安装目录,需绝对目录) --disable-debugging --disable-shared --enable-static

    3)make & make install

6. 将前面5个库的include文件拷贝到/usr/include, lib的文件拷贝到/usr/lib,并调用ldconfig。

    或者自定义include和lib目录,一并拷贝,并将该目录配置到/etc/ld.so.conf,然后调用ldconfig.

7. 将sox的bin目录工具play,rec拷贝到/usr/bin,即可以使用命令行play hello.mp3进行播放了。

关注微信公众号:嵌入式企鹅圈,获取更多原创资讯。

猜你喜欢

转载自blog.csdn.net/yueqian_scut/article/details/82966504
mp3