if i understand what you're asking correctly, you could just stash a
copy of the current pointer at the start of the process callback. then
(assuming there is only one pointer), the operation is atomic with
respect to the process callback: either it happens before you get the
copy of the pointer or not at all (since your copy of the pointer
won't be updated until the next time the callback is run).
Ah... you're right. Actualy this is pretty much straight forward.
Funny i didn't think of it myself :-)
There's one thing however, i am not completly sure about:
What happens if the working thread swaps buffers two times within one
cycle of the
playback thread? I'll try to do a simple diagram:
(Time) ---->
Playback
---------------------------------------------------------------------------------------------->
bang!
front==A ...
reading.....................................................still
reading from A
Worker
----------------------------------------------------->Worker------------------------------>
bang!
back==B, ...working on B...done...swap
back==A!...working on A
May not be a very common situation, but who knows. So i would have to
assure that
the worker thread does not process more than one "job" during one
playback cycle.
Or use more than two buffers.
Or did i miss something here?
if more
than one pointer is involved stick the sets into arrays and stash the
index to the current set instead of the pointers themselves.
This will propably not be the case. At least i think so right now.
hopefully that makes sense and is applicable.
It is indeed. I will try it.
Ah... another reply just droped into my mailbox <beep!> ... let's see
what Paul suggests. :-)
Thanks Rob,
Lukas