Mauro Carvalho Chehab wrote:
Both xawtv and tvtime use the same code for audio: http://git.linuxtv.org/cgit.cgi/xawtv3.git/tree/common/alsa_stream.c
There's an algorithm there that gets the period size form both the capture and the playback cards, trying to find a minimum period that would work properly for both.
Why are you trying to match period sizes? The sample clocks won't be synchronized anyway, so it is not possible to force them to happen at the same time.
Please note that for playback devices, the latency is the same as the buffer length, while for capture device, the latency is the same as the _period_ length. Therefore, it does not make sense to put an upper limit on the size of the capture buffer.
I do not think it is a good idea to stop the capture device when it overruns.
Regards, Clemens