编译speex / speexdsp for iOS audiounit边录边播,audioqueue边录边播

来源:互联网 发布:苹果手机上看图软件 编辑:程序博客网 时间:2024/06/08 10:45
参考文章: speex编译静态库for iOS
iOS静态库的编译
ios ffmpeg集成speex
OS X Lion, make/configure issue, trying to compile 64-bit libFLAC/libFLAC++(需越过高山)

speex部分:

一:官网下载最新的稳定版speex (目前是1.2.0)

speex 1.2.0 下载地址

二:配置configure文件

查看帮助
$ ./configure --help
里面会介绍相应参数的作用

在命令行输入
arm64
$ ./configure -prefix=/Users/lj/Desktop/speex-1.2.0/speexlib -host=armv64-apple-darwin --disable-shared --enable-static --disable-float-api --disable-binaries CC="xcrun -sdk iphoneos clang -mios-version-min=8.0 -fembed-bitcode -arch arm64"
armv7s
$ ./configure -prefix=/Users/lj/Desktop/speex-1.2.0/armv7s -host=armv7s-apple-darwin --disable-shared --enable-static --disable-float-api --disable-binaries CC="xcrun -sdk iphoneos clang -mios-version-min=8.0 -fembed-bitcode -arch armv7s"

armv7


参数:
-prefix:编译后内容存放地
-build:在什么宿主机上面编译(系统会自动识别,可以省略)
-host:交叉编译产生的项目要放在什么系统上运行(必填)
--enable-static:生成静态库
CC="xcrun -sdk iphoneos clang -mios-version-min=8.0 -fembed-bitcode -arch arm64"    使用xcode指定的编译器,最低版本是8,处理器架构为arm64

三:编译

$ make && make install

四:遇到的问题

1.在make命令是很多下面的报错
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: archive member: .libs/libspeex.a(exc_10_32_table.o) cputype (16777223) does not match previous archive members cputype (16777228) (all members must match)
解决办法:OS X Lion, make/configure issue, trying to compile 64-bit libFLAC/libFLAC++(需越过高山)
配置文件时加上: --disable-debug--disable-asm-optimizations --enable-sse

2.也是在make时报错
clang: warning: argument unused during compilation: '-msse' [-Wunused-command-line-argument]In file included from cb_search.c:39:In file included from ./vq.h:44:In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/xmmintrin.h:27:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/9.0.0/include/mmintrin.h:64:12: error: invalid conversion between vector type '__m64'      (vector of 1 'long long' value) and integer type 'int' of different size    return (__m64)__builtin_ia32_vec_init_v2si(__i, 0);           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
解决办法:删除配置选项--disable-asm-optimizations就好了,我也不明白为什么


SpeexDSP部分:

一:前序

从1.2rc2版本中,speex就将非压缩和解压缩部分放在了SpeexDSP中,从speexz中分离出来了,
打算编译,结果armv7,armv7s都编译好了,唯独arm64编译不过,因为什么arm架构处理器扩展结构(NEON)的问题一直编译不过,没法, 打算撸源码了

二:准备工作

1.下载SpeexDSP 版本1.2rc3 下载地址:https://www.speex.org/downloads/
2.从下载包里面去掉源码之外的东西,这个版本下,我就只留下了include和libspeesdsp两个文件夹

三:开撸

1.将文件拖进工程,编译报错:如下之类的地方报错
#ifndef FLOATING_POINT#error You now need to define either FIXED_POINT or FLOATING_POINT#endif#if defined (ARM4_ASM) || defined(ARM5E_ASM) || defined(BFIN_ASM)#error I suppose you can have a [ARM4/ARM5E/Blackfin] that has float instructions?#endif#ifdef FIXED_POINT_DEBUG#error "Don't you think enabling fixed-point is a good thing to do if you want to debug that?"#endif
找了好久都没找到,最后看到一篇相似的文章,
在工程中build-setting->preprocessor macros下修改如下,便能修复这个问题




2.运行,报错#include "speex/speex_preprocessor.h" file not found
删除speex/就可以了,这个错有很多,耐心改,
3.运行,还报错,提示有好多的main.o
去libspeexdsp文件夹下面删除四个测试文件
4.这下好了,成功运行;


下面部分是自己的测试代码,有点儿乱,但是可以看更新日志中的过程

https://github.com/liu5656/SpeexDemo

看我这么辛苦,给个start呗