Your application does not handle overruns and underruns (EPIPE indicates that either of these is happening). It also doesn't have any drift correction, so overruns/underruns are to be expected (the sample rate of the capture and playback stream is not guaranteed to be exactly matched).
By the way, there is a tool called 'alsaloop' (from alsa-utils) which does exactly the same thing, but with drift correction and more options ...
Maarten Baert
On 28/02/14 09:47, Vadim Izmalkov wrote:
Hello
I created simple application that makes audio pass-through (from analog input to analog output),
After 2-10 seconds get error like: AlsaPassthrough: pcm.c:693: snd_pcm_close: Assertion `pcm' failed. or write to audio interface failed (Broken pipe)
Seems I have problem with buffer size/time or somethink like that. Parameters used: Buffer - 100 ms / 4800 frames / 19200 bytes Period - 10 ms / 480 frames / 1920 bytes
Buffer length used 19200 bytes. char buffer[19200];
Write/read function used as follow snd_pcm_readi(pcm, buffer, frames); snd_pcm_writei(pcm, buffer, frames);
Have somebody any suggestion?