Alsa 全双工通信 [英] Alsa full duplex communication

查看:61
本文介绍了Alsa 全双工通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆