Re: memory footprint of AudioBuffer data copies

On Jul 30, 2013, at 10:04 AM, K. Gadd <kg@luminance.org> wrote:

> set() isn't automatically a race because you can have it acquire a mutex that the mixer holds when it's using the buffer as an input or output for mixing. Having a mutex acquired every time you set an element of a typed array does not seem like something VM implementers would have been excited to implement. The fact that timing is important is separate from the fact that unsynchronized access to a buffer from multiple threads is risky.

A mutex would be overkill here.  Both the start and end points occur on the main thread: after calling (e.g.) AudioBufferSourceNode.start(), further modifications to AudioBuffer would throw.  They would continue to throw until the ‘ended’ event fires.  Doing it this way (rather than acquiring a mutex when the audio thread begins accessing the memory) means the behavior is deterministic and specifiable.

-Jer

Received on Tuesday, 30 July 2013 17:15:55 UTC