日期:2014-05-16 浏览次数:20991 次
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <linux/soundcard.h>
int init_mixer("/dev/mixer", int *fd)
{
if ((*fd = open(device_name, O_WRONLY)) < 0){
fprintf(stderr, "Error opening %s: %s\n", device_name, strerror(errno));
return -1;
}
return 0;
}
int contrl_vol(int *fd, int increment)
{
int vol;
ioctl(*fd,MIXER_READ(SOUND_MIXER_VOLUME),&vol);
vol += increment;
ioctl(*fd,MIXER_WRITE(SOUND_MIXER_VOLUME),&vol);
return 0;
}