zikichombo / sio

sound I/O
BSD 3-Clause "New" or "Revised" License
25 stars 4 forks source link

add design doc for blocking implementation via callback #18

Closed wsc1 closed 5 years ago

wsc1 commented 5 years ago

comments welcome

wsc1 commented 5 years ago

This design assumes the callback interface will only pass the number of frames at a time requested unless its EOF (for capture at least).

While this has been true in my experience, it is not always guaranteed by the API.

Also, there are bugs w.r.t. assumptions of multiple calls: capture (as noted) is racy and playback and duplex only allow one call at a time if the underlying API implements the callbacks on 1 thread.

Finally the output callbacks (playback and duplex) do not allow to set the number of frames and thus don't allow precise definition of last sample. (this is true of AAudio as well, but should not be true of sio)

So, a bit of back to the drawing board. But the idea of communicating between C and Go by atomics only (no sys calls) seems ok; it's a start.

wsc1 commented 5 years ago

Most of the above have been fixed in #20