When operating in playback mode (i.e. AVTP talker) the plugin is expected to transmit the AVTPDUs in a periodical manner. The AVTPDU period is defined by the number of audio frames per AVTPDU and the sampling rate (see section 7.7 from AVTP spec [1] for further information).
To enforce the AVTPDU periodicity, this patch leverages the SO_TXTIME sockopt recently added to socket interface which enables the userspace to specify when a given packet should be transmitted. The plugin configures the transmission time from each AVTPDU so the expected transmission interval is maintained.
The SO_TXTIME feature works in conjunction with the Earliest TxTime First (ETF) qdisc. The ETF qdisc sorts packets from multiple sockets by the earliest transmission time and sends them to the network controller. It also enables offloading packet transmission to hardware in case the NIC supports it, providing more time accuracy. For further information about ETF qdisc, see tc-etf(8). The qdisc can be configured many ways, in doc/aaf.txt we provide an example.
Below follows some implementation highlights:
The packet transmission time is configured through socket control message interface so we now use sendmsg() to transmit AVTPDUs, instead of sendto().
sendmsg() API requires a msghdr struct which is initialized during device setup time. Strictly speaking, that struct is only required when operating in playback mode but we initialize it always, no matter if running in playback or capture mode. This makes hw_params() and hw_free() callbacks implementation way more simpler, specially on handling error cases.
[1] 1722-2016 - IEEE Standard for a Transport Protocol for Time-Sensitive Applications in Bridged Local Area Networks
Signed-off-by: Andre Guedes <andre.guedes@intel.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>