zoukankan      html  css  js  c++  java
  • Android : alsa-lib 移植

    一、官网下载lib源码

    网址:http://www.alsa-project.org/main/index.php/Download#alsa-lib

    左击:Stable Release列表中的【1.1.3】(移植的此版)

    修改后的源码压缩包下载链接:http://pan.baidu.com/s/1eSorykM 密码:rpiy

    二、安装android平台交叉编译工具链:

    1.用apt直接装:

     sudo apt install gcc-arm-linux-androideabi

     查看版本验证是否装成功:arm-linux-androideabi-gcc -v

    2.如果apt装的有问题就卸载:sudo apt remove --purge gcc-arm-linux-androideabi

     用以下提供的版本【arm-linux-androideabi-4.7.1】:链接:http://pan.baidu.com/s/1c16wgJe 密码:rkcs

     解压到任意目录下,然后配置环境变量:sudo gedit ~/.bashrc

     在~/.bashrc末尾添加如下:
       export PATH=/home/sheldon/bin:/home/sheldon/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games #default
     export PATH=${PATH}:/home/sheldon/workspace/tool/arm-linux-androideabi-4.7.1/bin
       export PATH=${PATH}:/home/sheldon/workspace/tool/opt/FriendlyARM/toolschain/4.4.3/bin

     然后在终端执行生效指令:source ~/.bashrc

     查看是否配置成功:arm-linux-androideabi-gcc -v

    三、修改&添加配置文件:

    修改alsa-lib源码 src/conf.c ,直接指定配置文件的位置(否则有open device fail的问题):

    //#define ALSA_CONFIG_PATH_DEFAULT ALSA_CONFIG_DIR "/alsa.conf" #define ALSA_CONFIG_PATH_DEFAULT "/system/usr/share/alsa/alsa.conf" //set by myself

    并将生成的 tmp/share/alsa/alsa.conf 文件 push 到机台的 /system/usr/share/alsa/alsa.conf

    或者

    尝试仅设置一下环境变量: export ALSA_CONFIG_PATH="/system/usr/share/alsa/alsa.conf"

    四、编译&生成静态库:

    1.配置编译项,生成Makefile:

     CC=arm-linux-androideabi-gcc ./configure --host=arm-linux prefix=$PWD/tmp --enable-shared=no --enable-static=yes --with-softfloat=yes --with-versioned=no

    2.编译和生成静态库:

     make | make install

       没问题的话静态库应该生成在配置指定的目录 : tmp/lib/libasound.a

    五、Android.mk中添加静态库使用:

    include $(CLEAR_VARS)
    LOCAL_MODULE := libasound
    LOCAL_SRC_FILES := libasound.a
    LOCAL_MODULE_TAGS := optional
    LOCAL_MODULE_OWNER := xxxx
    LOCAL_MODULE_SUFFIX := .a
    LOCAL_MODULE_CLASS := STATIC_LIBRARIES
    LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
    include $(BUILD_PREBUILT)  

    问题一:

    pcm_ladspa.c:1119:82: error: 'struct lconv' has no member named 'decimal_point' Makefile:488: recipe for target 'pcm_ladspa.lo' failed

    使用软浮点:

    --with-softfloat=yes

    问题二:

    parser.c:1427:54: error: 'versionsort' undeclared (first use in this function) parser.c:1427:54: note: each undeclared identifier is reported only once for each function it appears in

    网上说法是uClib库版本太低,先直接用alphasort这个函数:

    更改位置:parser.c and conf.c

    //#define SORTFUNC versionsort

    //#else

    #define SORTFUNC alphasort

    问题三:

    链接静态库时有snd_pcm_hwsync相关警告

    直接把snd_pcm_hwsync调用的地方注释掉。

  • 相关阅读:
    深圳和上海
    肖舸的“畅销门”和“卓越门”
    一件小事引发的辞职——团队里的Y君
    同洲、宇龙手机源代码之争
    《过得去》
    评肖舸之《0bug一书给谁带来了奶酪?》
    《观止》点滴
    webgame 地图加载(论坛摘录)
    分块加载(转)
    45度游戏的另类深度排序(copyPixels)
  • 原文地址:https://www.cnblogs.com/blogs-of-lxl/p/6781082.html
Copyright © 2011-2022 走看看