[webkit-dev] Using JavaScriptCore in an audio context

Stéphane Letz letz at grame.fr
Tue Sep 22 08:57:33 PDT 2015

Le 22 sept. 2015 à 17:47, Darin Adler <darin at apple.com> a écrit :

>> On Sep 22, 2015, at 8:32 AM, Stéphane Letz <letz at grame.fr> wrote:
>> since the asm.js code does not allocate memory
> Unlike C and C++, JavaScript doesn’t directly expose a concept of “allocating memory” so I’m not sure what it means to say that. Any JavaScript code, including “asm.js code” may involve allocation of memory.
> — Darin

Well we already use the same Domain Specific Language generated asm.js module in the context of the WebAudio API: so basically using a ScriptProcessor node, plugging our asm.js  in the "onprocess" method, than use the resulting WebAudio node as any regular ScriptProcessor in a WebAudio audio graph. This work correctly AFAICT : the "compute" function basically does pure mathematical operations on float located is an "allocated once at the beginning" JS ArrayBuffer.

The point is to know if 1) calling asm.js code from the real-time process is safe of not 2) how can we transfer memory, avoiding copies if possible of at least minimizing them, something like  "copy C buffer to JS buffer" ===> call "compute" ===> copy JS buffer to C buffer.


More information about the webkit-dev mailing list