javascript - Use Module.HEAP8.set Get messed data -
i use emscripten compile c code asm.js c code this:
int _call_main(char* p, int number)//p start arrary, number lengh
i want send bytearray data c code, js code this:
var decode_encode_audio = module.cwrap('_call_main', 'number', ['array','number']); ........ var bytearray = new uint8array(message.data);//audio data var offset = module._malloc(70000); module.heap8.set(bytearray, offset); decode_encode_audio(offset , bytearray.length);
in c code, print point p array, got messed data, start part , end part of p correct(i save file), however, in middle part messed.i replace function(module.heap8.set) [module.heapu8.set],also got error. don't know why?
i change js code :
var decode_encode_audio = module.cwrap('_call_main', 'number', ['number','number']);//not array ........ var bytearray = new uint8array(message.data);//audio data //var offset = module._malloc(70000); //module.heap8.set(bytearray, offset); decode_encode_audio(bytearray, bytearray.length);
i got correct data.
can tell me what's wrong "module.heap8.set" method.
you writing unsigned data uint8array
signed view heap8
. should use heapu8
, used unsigned data.
Comments
Post a Comment