Set new macro N_CHANS to 256 - the length of the chanlist[] array.
If the '-n' option sets options.n_chan higher than N_CHANS, reduce it to
avoid overrunning the chanlist[] array.
Use local function prepare_cmd_lib() -- which uses
comedi_get_cmd_generic_timed() -- to prepare a good command for the
device. Bail out early if it fails.
If the '-s' option has not been specified, default to using the current
'read' subdevice if there is one instead of defaulting to subdevice 0.
Fall back to using subdevice 0 if there is no 'read' subdevice.
Attempt to make the streaming command demos work if the specified
subdevice is not the default 'read' or 'write' subdevice (depending on
the direction of the command).
This uses the new comedi_set_read_subdevice() and
comedi_set_write_subdevice() functions.
Changing the read or write subdevice is currently supported only by the
Linux "in-tree" version of Comedi since kernel version 3.19.
Currently, the 'front' and 'back' variables are of type 'int' (signed
32-bit integers). The loop will break when 'front < back', which will
happen when more than 'INT_MAX' bytes of data have been produced.
Redefine them as 'unsigned int' and also allow 'front < back' which will
happen when more than 'UINT_MAX' bytes of data have been produced.
Because the buffer size is not necessarily a power of 2, we can no
longer just use '(back + i) % size' to get the buffer position
corresponding to 'back + i', so introduce a new variable 'bufpos' to
keep track of the buffer position.
Also allow for subdevices that set the 'SDF_LSAMPL' flag to indicate
they use the large (32-bit, 'lsampl_t') sample type instead of the small
(16-bit, 'sampl_t') sample type.
Also, rename the buffer size variable 'size' to 'bufsize'.