2 Aug
2016
2 Aug
'16
9:55 a.m.
Alan Young wrote:
Stepping back for a moment, the delay calculation essentially consists of two parts:
- How much data is still in the ring buffer.
- How much data has been removed from the ring buffer but not yet played out.
[...] The more that I think about it the more it seems to me that using a time-based estimate for position (hw_ptr), outside of an interrupt callback, will always be more accurate than that returned by substream->ops->pointer().
Please note that "hw_ptr" (or "avail" in the API) specifies the DMA position, i.e., it is guaranteed that the samples up to this position have been handled by the DMA controller and can now be accessed by the program. An estimate that gets this wrong can lead to data corruption.
Using an estimate for the delay is perfectly fine.
Regards, Clemens