[alsa-devel] Some questions related to ALSA based duplex audio processing

Fons Adriaensen fons at linuxaudio.org
Tue Jan 31 13:10:19 CET 2012


On Tue, Jan 31, 2012 at 12:39:55PM +0100, public-hk wrote:

> So, the conclusion is that it is not really defined and I have to deal 
> with synchronization of
> input and output myself, is that the right interpretation?

If the capture and playback devices use the same sample clock
(which will be the case if they refer to the same soundcard),
and they are started together, they will remain in sync and
both sides will be ready at the same time - any difference
will be trivially small compared to the period time.

If they don't use the same sample clock you have a difficult
problem: you need adaptive resampling (which is the subject
of my proposed LAC paper).

So in practice, if you use one and the same soundcard for input
and output there is nothing to be gained from keeping the two
separate, and in most cases the driver will allow then to be
'linked', that is started and stopped with a single call.  

Waiting for ALSA devices using poll() can be complicated.
In the general case there will be more than one filedesc,
the poll events returned don't always correspond to the
logical direction and have to reworked, you need to take
care of error recovery, etc. This is one of the many things
zita-alsa-pcmi will do for you, just call pcm_wait(). When
it returns you can read and write one period (in theory
there could be more than one, but that is quite exceptional
- I've never seen it happen). 


Ciao,

-- 
FA

Vor uns liegt ein weites Tal, die Sonne scheint - ein Glitzerstrahl.



More information about the Alsa-devel mailing list