This is not exactly the answer to your question, but hopefully it explains how this process works. Since you did not specify what equipment you use to convert AD, this is probably the best thing you can do:
With audio equipment that faces the same problem, the solution comes from the hardware and drivers working together: whenever the equipment fills a sufficient amount of buffer, it signals the driver (through an interrupt or some similar mechanism). In some cases, it is also possible that the driver tried out hardware or something like that, but this is a less efficient solution, and I'm not sure if anyone does this more (maybe on cheaper hardware?). From there, the driver process can invoke the right in the end-user process, or it can simply mark the corresponding end-user process as โrunnableโ. In any case, control must be transferred to the end-user process.
For this to happen, the end-user process must work with a higher priority than all the others that occupy the central processors at this moment. To guarantee that your process will always be the first in the queue, you can run it with high priority, with the appropriate permissions, you can even run very high priorities.
The time it takes for a top-priority process to go from runnable to running is sometimes called OS latency, although I'm sure there is a more specific technical term. Linux latency is about 1 ms, but since it is not a "hard" real-time operating system, it is not a guarantee. If it is too long to process your chunks of data, you may have to mask some of them in your driver.
source share