当前位置: 技术问答>linux和unix
linux 如何解决音频传输延迟,请高手指教,下面是我的客户端程序
来源: 互联网 发布时间:2017-04-05
本文导语: 这是客户端程序,服务端程序也差不多,两端可以实现音频传输,但是延迟很大,大概有5秒,要怎样改程序才能尽量减少延迟????????????????? /*#include #include #include #include #include */ #incl...
这是客户端程序,服务端程序也差不多,两端可以实现音频传输,但是延迟很大,大概有5秒,要怎样改程序才能尽量减少延迟?????????????????
/*#include
#include
#include
#include
#include
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define PORT 8888
#define SERVER_IP "192.168.1.105"
#define BUFSIZE 4096
#define RATE 8000
#define SIZE 16
#define CHANNELS 2
#define RDONLY 0
#define WRONLY 1
int read_fd; //读音频文件
int write_fd; //写音频文件
pthread_mutex_t mutex;
unsigned char write_buf[BUFSIZE];
unsigned char read_buf[BUFSIZE];
int SoundCapture(int Flag);
//接收声音
void *sound_listen(void *arg)
{
char recv_buf[BUFSIZE];
int *parg=(int *)arg;
int listen_fd=*parg;
printf("listen_fd=%dn",listen_fd);
while(1)
{
memset(read_buf,0,1024);
int ret = recv(listen_fd, (void *)recv_buf, BUFSIZE, 0);
if(ret
/*#include
#include
#include
#include
#include
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define PORT 8888
#define SERVER_IP "192.168.1.105"
#define BUFSIZE 4096
#define RATE 8000
#define SIZE 16
#define CHANNELS 2
#define RDONLY 0
#define WRONLY 1
int read_fd; //读音频文件
int write_fd; //写音频文件
pthread_mutex_t mutex;
unsigned char write_buf[BUFSIZE];
unsigned char read_buf[BUFSIZE];
int SoundCapture(int Flag);
//接收声音
void *sound_listen(void *arg)
{
char recv_buf[BUFSIZE];
int *parg=(int *)arg;
int listen_fd=*parg;
printf("listen_fd=%dn",listen_fd);
while(1)
{
memset(read_buf,0,1024);
int ret = recv(listen_fd, (void *)recv_buf, BUFSIZE, 0);
if(ret