Linux环境下用c语言写的播放wav文件的小程序
#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 RATE 11025
#define SIZE 16
#define CHANNELS
2 // 1表示单声道,2为立体声
/* ................ */
unsigned char
buf[RATE*SIZE/8]; //buf里面正好放一秒钟的音频,下面的计时还要用
int main()
{
int fd;
int wavfd; //wav文件的描述符
int arg; /* ..ioctl..... */
int status; /*
........ */
/* ...... */
fd = open("/dev/dsp",
O_RDWR);
if (fd < 0) {
printf("open of /dev/dsp failed");
exit(1);
}
wavfd = open("a.wav",O_RDONLY);
if (wavfd
< 0) {
printf("open of wav 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)
&nb
相关文档:
这个DDD安装了一晚上,记录步骤如下:
1.下载lesstif-0.93.40.tar.bz2(ddd-3.3.11.tar.gz 的文档中说这个稳定我就用这个了)从http://www.ibiblio.org/pub/X11/lesstif/srcdist/放到/usr/local下,然后是三部曲:./configure ,make,make install
2.下载ddd-3.3.11.tar.gz 从http://download.chinaunix.net/download/0003 ......
(一)中文字体的显示
(首先)用setup命令 开启“setup”对话框 --- 选择“service setup” 把“xfs” disable掉。
然后接下来:
(1)copy "c:/windows/fonts/simsun.ttc" to Linux directory : "/usr/share/fonts/liberation"
(2)edit "/etc/sysconfig/i1 ......
1.下载apache源码包,进入页面http://httpd.apache.org/download.cgi,下来后放入/usr/local/src目录中
2.解压:
cd /usr/local/src
tar --zxvf httpd-2.2.15.tar.gz
3.cd httpd-2.2.15
./configure --prefix=/usr/local/src/apache2 \
--enable-so \
--enable-rewrite
make;make install
4.启动服务 service httpd s ......
看linux内核很容易被struct address_space 这个结构迷惑,它是代表某个地址空间吗?实际上不是的,它是用于管理文件(struct inode)映射到内存的页面(struct page)的;与之对应,address_space_operations 就是用来操作该文件映射到内存的页面,比如把内存中的修改写回文件、从文件中读入数据到页面缓冲等。
& ......