河谷吉他 发表于 2012-5-12 15:50:48

【急】ok6410实时录放音时,存在延时,回声问题,请求解决!

本帖最后由 河谷吉他 于 2012-5-12 19:02 编辑

开发板:ok6410
内核:linux2.6.28

----------------------------------我是美丽的分割线--------------------------------------------

问题1:实时录放音时,存在延时,和回音,请求帮助!
speex可以消除回音,谁有源码,求分享,729438647@qq.com
以下是源码:
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <stdlib.h>
#include <stdio.h>
#include <linux/soundcard.h>

#define LENGTH 60    /* 存储秒数 60ms*/
#define RATE 8000   /* 采样频率 */
#define SIZE 16      /* 量化位数 */
#define CHANNELS 1/* 声道数目 */
/* 用于保存数字音频数据的内存缓冲区 */
unsigned char buf;
int main()
{
        int fd;        /* 声音设备的文件描述符 */
        int arg;        /* 用于ioctl调用的参数 */
        int status;   /* 系统调用的返回值 */
        /* 打开声音设备 */
        fd = open("/dev/dsp", O_RDWR);
        if (fd < 0) {
                perror("open of /dev/dsp failed");
                exit(1);
        }
        /* 设置采样时的量化位数 */
        arg = SIZE;
        status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
        if (status == -1)
        perror("SOUND_PCM_WRITE_BITS ioctl failed");
        if (arg != SIZE)
        perror("unable to set sample size");

        /* 设置采样时的声道数目 */
        arg = CHANNELS;
        status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
        if (status == -1)
        perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
        if (arg != CHANNELS)
        perror("unable to set number of channels");
        /* 设置采样时的采样频率 */
        arg = RATE;
        status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
        if (status == -1)
        perror("SOUND_PCM_WRITE_WRITE ioctl failed");
        /* 循环,直到按下Control-C */
        while (1) {
                //printf("Say something:\n");
                status = read(fd, buf, sizeof(buf)); /* 录音 */
                if (status != sizeof(buf))
                perror("read wrong number of bytes");
                //printf("You said:\n");
                status = write(fd, buf, sizeof(buf)); /* 回放 */
                if (status != sizeof(buf))
                        perror("wrote wrong number of bytes");
                //   /* 在继续录音前等待回放结束 */
                //   status = ioctl(fd, SOUND_PCM_SYNC, 0);
                //   if (status == -1)
                //                 perror("SOUND_PCM_SYNC ioctl failed");
        }
}
----------------------------------我是美丽的分割线--------------------------------------------
问题2:源码已解决,求测试程序,speex移植分享给大家。
speex的移植
把speex移植到arm开发板
1:下载libogg_1.1.0.orig.tar.gz: (http://downloads.xiph.org/releases/ogg/)
   tar -xf libogg_1.1.0.orig.tar.gz
2: cd libogg_1.1.0
   ./configure --prefix="安装的目录" --host="安装的平台(arm-linux)";初始化
   ./make 编译
   ./make install安装
3:下载speex,解压,(http://www.speex.org/)
./configure --prefix="" --host="" --with-ogg="ogg的安装目录" --with-oggheader="ogg的头文件"
--with-ogg-libraries="ogg的库"
4:把安装好的speex/lib下的libspeex.so.*文件拷贝到arm的lib下,也可以export LD_LIBRARE_PATH="你的路径"
4:就可以运行你的程序了
----------------------------------我是美丽的分割线--------------------------------------------

飞凌-fatfish 发表于 2012-5-12 23:03:20

虽然是老内核的问题,楼主也是很用心了。而且无私的奉献出来,很赞。只得大家学习。
2.6.28不再更新。此贴会收集起来为后来人提供。
页: [1]
查看完整版本: 【急】ok6410实时录放音时,存在延时,回声问题,请求解决!