[alsa-devel] [PATCH 09/39] firewire-lib: Add sort function for transmitted packet

Clemens Ladisch clemens at ladisch.de
Sun Mar 9 22:07:05 CET 2014

Takashi Sakamoto wrote:
> This commit is to assure the continuity of timestamp in in-packets
> transmitted by devices.
> Fireworks with firmware version 5.5 or former is a type of device which
> transmits packets with a bit disorder.

Then this should be done only when we actually have one of these known
devices (and only when this error is known to happen, i.e., directly
after a no-data packet); otherwise, this could, in theory, interfere with
dropped packets.

> This commit add sorting of in-packets. When callback of receive-context
> is processed, the parameters of in-packets are stored in sort table and
> sorted by its value of data block counter. The sort algorism works faster
> in ordered sequence than in messy sequence. This is convinient for this
> purpose because the sequence is assumed not to be so messy. After sorting,
> packets are processed except for a last few packets in sort table. These
> packets are stored in buffer once and used in next cycle.

Only a single packet is out of order, i.e., only two packets are exchanged.
So it is not necessary to run a general-purpose sorting algorithm; it would
be sufficient to store a single packet if it is out of order.

> +	if (s->sort_table != NULL)
> +		kfree(s->sort_table);

A NULL check is not necessary for kfree().


More information about the Alsa-devel mailing list