I'm using the Windows core audio functions, mostly WASAPI, to render an exclusive stream, following the example in Exclusive-Mode Streams.
This creates two alternating buffers played and filled alternately. There is an event tied to buffer completion that wakes the thread so it can refill the buffer just completed. GETPOSITION shows that the thread is waked when the current buffer is at frame 147 of a 160 frame buffer. This leaves me with 13/160 of a buffer time to get a new buffer, fill it, and release it. I have a lot of calculation to do, this isn't enough time. I suppose I could keep control of the processor instead of sleeping when a buffer is filled, but that doesn't seem like the right solution.
Further, even though my process is "PRO AUDIO" and has a priority of 25, sometimes the buffer completion event is delayed still farther, so the system starts replaying an unfilled buffer. I haven't found any discussion of how this timing is supposed to work, or how it can be controlled. I expected the buffer completion event to arrive within a small number of frames into the next buffer. Is anyone familiar with this stuff? Either with a solution or a clue about where to look for one?