我正在尝试使用emscripten将libsoxr构建为WebAssembly。在调用soxr_create函数时,我尝试的所有操作都会导致RuntimeError: function signature mismatch错误。我使用的是emscripten的latest标签。我也尝试了所提供的示例,并且行为是相同的。我试过使用NodeJS和Chromium。
下面是重现的方法:
git clone https://git.code.sf.net/p/soxr/code
cd soxr
emcmake cmake -DBUILD_EXAMPLES=ON .
emmake make
node examples/2-stream.js堆栈跟踪为:
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
at wasm-function[50]:0xf72e
at wasm-function[49]:0xe90d
at wasm-function[60]:0x1057f
at wasm-function[14]:0xcac
at wasm-function[13]:0xb53
at wasm-function[11]:0x699
...当仅使用调用soxr_create的main函数构建文件并使用-g --profiling构建文件时,下面是我获得的堆栈跟踪:
exception thrown: RuntimeError: function signature mismatch,RuntimeError: function signature mismatch
at dft_stage_init (wasm-function[68]:0x1b8e2)
at _soxr_init (wasm-function[66]:0x190be)
at rate_create (wasm-function[88]:0x1f8fa)
at initialise (wasm-function[124]:0x43c90)
at soxr_set_io_ratio (wasm-function[122]:0x4373f)
at soxr_create (wasm-function[119]:0x43213)
at __original_main (wasm-function[135]:0x45646)
at main (wasm-function[136]:0x45684)
at /home/geekuillaume/code/wasm-audio-resampler/soxr_wasm.js:1635:22
at callMain (/home/geekuillaume/code/wasm-audio-resampler/soxr_wasm.js:2377:15)我试过使用emscripten消毒剂,但它没有任何作用。
发布于 2020-07-20 20:37:41
找到了问题所在。Soxr库错误地转换了函数指针。指向的函数不需要任何参数,但被强制转换为接收一个int作为参数的函数。我写了一个补丁来修复这个问题,一切都运行得很好!在Emscripten documentation中有更多关于这方面的信息。
https://stackoverflow.com/questions/62983078
复制相似问题