BBS水木清华站∶精华区
发信人: bcl (晓颖), 信区: Linux
标 题: 音量控制程序
发信站: BBS 水木清华站 (Fri Nov 19 09:44:26 1999) WWW-POST
/*-------Sound Controler----------------------*/
/*-------built by ever,Aug 7,1999-------------*/
/*-------please compile like this:------------*/
/*-------c++ -o sndctrl sndctrl.c-------------*/
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
#include <stdio.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#define BASE_VALUE 257
main(int argc,char *argv[])
{
int mixer_fd=0;
char *names[SOUND_MIXER_NRDEVICES]=SOUND_DEVICE_LABELS;
int value;
printf("\nusage:%s dev_no.[0..24] value[0..100]\n\n",argv[0]);
printf("eg. %s 0 100\n",argv[0]);
printf(" will change the volume to MAX volume.\n\n");
printf("The dev_no. are as below:\n");
for (int i=0;i<SOUND_MIXER_NRDEVICES;i++){
if (i%3==0) printf("\n");
printf("%s:%d\t\t",names[i],i);
}
printf("\n\n");
if (argc<3)
exit(1);
if (mixer_fd = open("/dev/mixer",O_RDWR)){
printf("Mixer opened successfully,working...\n");
value=BASE_VALUE*atoi(argv[2]);
if (ioctl(mixer_fd,MIXER_WRITE(atoi(argv[1])),&value)==0)
printf("successfully.....");
else printf("unsuccessfully.....");
printf("done.\n");
}
else printf("can't open /dev/mixer error....\n");
}
--
I'm always here.
Yours,
Shell.Y.bcl
※ 来源:·BBS 水木清华站 bbs.net.tsinghua.edu.cn·[FROM: 202.119.37.5]
BBS水木清华站∶精华区