Repository navigation
Does CPAL add any latency? #1364
|
Does CPAL add any latency for any of the backends? PortAudio has a major issue with doubling the latency with its JACK implementation and I am hoping CPAL has no such problems. Regardless of the answer, it would be good to document it. |
Replies: 1 comment
|
There shouldn't be any. In many cases, cpal directly forwards the hardware buffers provided by the underlying API to the user callback. For instance, on Windows, WASAPI signals a waitable object on every period, and cpal maps WASAPI's buffer as the slice that is passed to the data callback, which means you are reading from/writing to WASAPIs buffer directly. The current ASIO implementation does funnel everything through a staging buffer because it needs to (de-)interleave multi-channel streams, but this happens entirely within the same buffer cycle, so it doesn't affect total latency. I'm personally not familiar with the other platforms, so I can't make any guarantees there, but if one of cpal's backends increases latency by queueing up stream data, then I'd consider that a bug. |
There shouldn't be any.
In many cases, cpal directly forwards the hardware buffers provided by the underlying API to the user callback. For instance, on Windows, WASAPI signals a waitable object on every period, and cpal maps WASAPI's buffer as the slice that is passed to the data callback, which means you are reading from/writing to WASAPIs buffer directly. The current ASIO implementation does funnel everything through a staging buffer because it needs to (de-)interleave multi-channel streams, but this happens entirely within the same buffer cycle, so it doesn't affect total latency.
I'm personally not familiar with the other platforms, so I can't make any guarantees there, but if one of…