/*
* mixer.c test sound
*/
#include
#include
#include
#include
#include
#include
#include
#include
int main (int argc, char* argv[])
{
int fd,volume_read,volume_write;
if(argc != 2)
{
printf("Usage: %s volume_write\n",argv[0]);
printf("Example: %s 30\n",argv[0]);
}
if(argc == 2)
volume_write = atoi(argv[1]);
if(volume_write < 0 || volume_write > 100)
volume_read = 30;
fd = open("/dev/mixer",O_RDWR);
if(fd < 0)
{
perror("Open mixer" );
exit(-1);
}
do{
ioctl(fd,SOUND_MIXER_WRITE_VOLUME,&volume_write);
ioctl(fd,SOUND_MIXER_READ_VOLUME,&volume_read);
printf("volume_read = %d\n",volume_read);
volume_write++;
sleep(2);
}while(volume_write < 100);
close(fd);
}
阅读(1260) | 评论(0) | 转发(0) |