主题 : mini2440音频设备的调用 复制链接 | 浏览器收藏 | 打印
级别: 新手上路
UID: 56358
精华: 0
发帖: 4
金钱: 20 两
威望: 4 点
综合积分: 8 分
注册时间: 2011-10-05
最后登录: 2011-12-23
楼主  发表于: 2011-11-21 22:10

 mini2440音频设备的调用

你好。我的板是mini2440+linux,我在一段程序中这样调用音频设备,但是无法打开,麻烦帮我看看,指教一下,谢谢啦。
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <errno.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include  <sys/soundcard.h>
#include <fcntl.h>

int main(int argc, char **argv)
{
int sockfd;
int count = 0;
int flag;

int i;
int audio_id;


if ( (audio_id = open ( "/dev/audio", O_RDWR ) ) < 0 )
{
fprintf (stderr, " Can't open sound device!\n");
exit ( -1 ) ;
}
……
……
就这样,运行的时候一直返回 Can't open sound device
^很多问题的背后都是简单的原因......
级别: 荣誉会员
UID: 34780
精华: 0
发帖: 1219
金钱: 6230 两
威望: 1246 点
综合积分: 2438 分
注册时间: 2010-12-21
最后登录: 2017-09-18
1楼  发表于: 2011-11-22 09:47
你可以把errno打印出来看看具体是什么错
级别: 新手上路
UID: 56358
精华: 0
发帖: 4
金钱: 20 两
威望: 4 点
综合积分: 8 分
注册时间: 2011-10-05
最后登录: 2011-12-23
2楼  发表于: 2011-11-28 10:14

 回 1楼(911gt3) 的帖子

谢谢你的指点。我后来请教了师兄,他帮我指出错误了。
是因为这个音频设备不能以读写的方式打开,只能以只读或只写的方式打开。