主题 : 2.6.29录音问题 复制链接 | 浏览器收藏 | 打印
级别: 侠客
UID: 2375
精华: 0
发帖: 51
金钱: 490 两
威望: 206 点
综合积分: 102 分
注册时间: 2008-11-14
最后登录: 2014-07-16
楼主  发表于: 2009-07-29 16:14

 2.6.29录音问题

板子是 mini2440, 内核是2.6.29,朋友写的一个录音测试程序:
复制代码
  1. // testdev.c
  2. #include <sys/ioctl.h>
  3. #include <sys/time.h>
  4. #include <fcntl.h>
  5. #include <stdlib.h>
  6. int main(int argc, char *argv[])
  7. {
  8.   int fd;
  9.   fd=open(argv[1], O_RDWR|O_NONBLOCK);
  10.   if (fd<0)
  11.     {
  12.       perror("error opening opening AUDIO device");
  13.       exit(1);
  14.     }
  15.   printf("open ok\n");
  16.   exit(0);


运行./testdev /dev/dsp 就报错,改成
复制代码
  1. fd=open(argv[1], 0);

就可以运行
另外,如果
复制代码
  1. dd if=/dev/dsp of=/dev/null
然后Ctrl-C的话显示:
复制代码
  1. 18+0 records in
  2. 17+0 records out
  3. 8704 bytes (8.7k) copied, 1.17577s, 7.4kB/s

但看不到任何东西

这是内核有问题还是程序有问题捏
怎么解决?大侠们支支招啊
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
1楼  发表于: 2009-07-29 17:02
dd if=/dev/dsp of=/dev/null

输出到/dev/null,你还想看到什么?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 2375
精华: 0
发帖: 51
金钱: 490 两
威望: 206 点
综合积分: 102 分
注册时间: 2008-11-14
最后登录: 2014-07-16
2楼  发表于: 2009-07-29 17:14
额。。。
这是次要的
关键是为什么不能录音呢?
是哪的问题?
请版主请教
级别: 侠客
UID: 2375
精华: 0
发帖: 51
金钱: 490 两
威望: 206 点
综合积分: 102 分
注册时间: 2008-11-14
最后登录: 2014-07-16
3楼  发表于: 2009-07-29 17:14
打错,请版主赐教
级别: 侠客
UID: 2375
精华: 0
发帖: 51
金钱: 490 两
威望: 206 点
综合积分: 102 分
注册时间: 2008-11-14
最后登录: 2014-07-16
4楼  发表于: 2009-07-29 17:21
http://www.aiothome.com/bbs/read.php?tid-1925-keyword-dev%2Fdsp.html
跟这个是同一个问题吗?
必须得把dsp_fd = open("/dev/dsp", O_RDWR);
改为:
dsp_fd = open("/dev/dsp", O_RDONLY?

有没有同时读写的办法呢?
VOIP项目,光读不写搞不成事啊~
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
5楼  发表于: 2009-07-29 17:21
引用第2楼zhenhua0018于2009-07-29 17:14发表的  :
额。。。
这是次要的
关键是为什么不能录音呢?
是哪的问题?
请版主请教

"/dev/dsp"不能以O_RDWR方式打开,已经有N多关于这个问题的老贴了,为什么不先搜索一下再问?
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
*無鈳取玳
级别: 论坛版主
UID: 27
精华: 12
发帖: 5398
金钱: 40120 两
威望: 17929 点
综合积分: 11036 分
注册时间: 2008-01-16
最后登录: 2014-11-22
6楼  发表于: 2009-07-29 17:25
引用第4楼zhenhua0018于2009-07-29 17:21发表的  :
http://www.aiothome.com/bbs/read.php?tid-1925-keyword-dev%2Fdsp.html
跟这个是同一个问题吗?
必须得把dsp_fd = open("/dev/dsp", O_RDWR);
改为:
dsp_fd = open("/dev/dsp", O_RDONLY?
.......

录音的时候用O_RDONLY, 放音的时候用O_WRONLY;
如果你还觉得不爽,可以换一个支持O_RDWR的codec驱动。嵌入式Linux本来就是用来折腾的
"If you have an apple and I have an apple and we exchange apples, then you and I will
still each have one apple. But if you have an idea and I have an idea and we exchange
these ideas, then each of us will have two ideas."
级别: 侠客
UID: 2375
精华: 0
发帖: 51
金钱: 490 两
威望: 206 点
综合积分: 102 分
注册时间: 2008-11-14
最后登录: 2014-07-16
7楼  发表于: 2009-07-29 17:33
顶你最后一句
级别: 新手上路
UID: 7312
精华: 0
发帖: 26
金钱: 260 两
威望: 245 点
综合积分: 52 分
注册时间: 2009-07-09
最后登录: 2010-10-04
8楼  发表于: 2009-07-29 18:17
顶呀~~嵌入式Linux就是无限的折腾~~
级别: 新手上路
UID: 36113
精华: 0
发帖: 14
金钱: 80 两
威望: 16 点
综合积分: 28 分
注册时间: 2011-01-11
最后登录: 2011-09-30
9楼  发表于: 2011-01-12 00:10
可即使是O_RDONLY,也有bug,耳机会同时把MIC声音同步播放出来呀,也搞不成VOIP呀