Alsa全双工通信 [英] Alsa full duplex communication
问题描述
我想使用alsa实现全双工通信.我首先编写了捕获和回放程序,然后使用UDP通信将数据从捕获过程传输到回放过程.当我运行两个正在捕获一个而另一个正在播放的进程时,它工作正常(将此视为从A到B的半双工),当我尝试实现另一个半双工(从B到A的半双工)时,问题就来了那么我会收到管道破损错误同时从麦克风读取数据.该如何解决?任何帮助,谢谢.
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
推荐答案
当应用程序必须等待PCM设备时,它将进入睡眠状态并在下一个周期边界被唤醒.因此,读取/写入的最佳大小是一个周期(或该周期的倍数).
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.)
这篇关于Alsa全双工通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!