On 1/6/17 10:08 AM, Ricardo Biehl wrote:
2017-01-06 6:09 GMT-02:00, Clemens Ladisch clemens@ladisch.de:
Are you talking about code in your driver (where you are responsible for asking the hardware), or user space code (where you must not directly read hw_ptr)? What is the actual problem you're trying to solve?
Hello! I'm developing a "live microphone system over local network" which are user space programs (clients => server) transferring audio nearly real-time (human imperceptible latency). I need to elaborate a good solution of implementation to have everything working as expected -- networking, scheduling, IO management etc -- However I need at first make sure I can get control over audio.
I decided to use ioctl() level of communication with ALSA in kernel, and what I need is synchronization :-) I must know which sample the hardware is currently processing to prevent a lot of losses or latency increasing.
I would hate to sound pedantic but sample-accurate control (10us at 48kHz) is far from trivial. The hw_ptr points to the ring buffer, but you may have additional samples queued up in DMA transfers, FIFOS, codecs and last some analog delays. On a network-based solution the different components typically don't use the same audio clock and you will have to deal with drifts between source and sink. Best of luck.