问题
I want to implement full duplex communication using alsa. I first wrote capture and playback programs and i am transferring data from captured process to playback process using UDP communication. It is working fine when i was running two processes where one is capturing and another is playing(consider this as half duplex from A to B) , the problem comes when i was trying to implement another half duplex(Half duplex from B to A) then I am getting Broken Pipe error while reading the data from Mic. How to resolve this?. Any help, thanks in advance.
Note: I am running two processes on different systems
回答1:
When the application has to wait for a PCM device, it goes to sleep and gets woken up at the next period boundary. Therefore, the optimal size to read/write is one period (or a multiple of that).
You should read/write sample data as soon as some frames are available.
To reduce the chances of an over/underrun, increase the buffer size. (On capture devices, increasing the buffer size does not increase latency.)
来源:https://stackoverflow.com/questions/20039573/alsa-full-duplex-communication