3 --- cmp3volume.c.orig Fri Feb 9 15:54:18 2001
4 +++ cmp3volume.c Fri Feb 9 23:45:24 2001
9 -#include<sys/soundcard.h>
10 +#if defined(__NetBSD__)
11 +#include <sys/audioio.h>
13 +#include <sys/soundcard.h>
16 static int mixernum, /* ID number for the mixer */
17 vol; /* Current volume level */
19 * Initialize volume control
21 ****************************************************************************/
22 +#if defined(__NetBSD__)
25 +mixer_ctrl_t *m, *values;
27 +extern void initvol()
31 + mixer_devinfo_t dinfo, *infos;
33 + mixer_device = getenv("MIXERDEVICE");
34 + if (mixer_device == NULL)
35 + mixer_device = "/dev/mixer0";
37 + if ((mixernum=open(mixer_device, O_RDWR)) < 0) {
38 + fprintf(stderr, "open mixer device: %s", strerror(errno));
42 + for (ndev = 0; ; ndev++) {
44 + if (ioctl(mixernum, AUDIO_MIXER_DEVINFO, &dinfo) < 0)
47 + infos = calloc(ndev, sizeof *infos);
48 + values = calloc(ndev, sizeof *values);
50 + for (i = 0; i < ndev; i++) {
52 + ioctl(mixernum, AUDIO_MIXER_DEVINFO, &infos[i]);
55 + for (i = 0; i < ndev; i++) {
56 + if (infos[i].type == AUDIO_MIXER_VALUE) {
58 + values[i].type = infos[i].type;
60 + if (strcmp(infos[i].label.name, AudioNdac) == 0) {
66 + values[device_id].un.value.num_channels = 2;
68 + m = &values[device_id];
69 + ioctl(mixernum, AUDIO_MIXER_READ, m);
70 + vol = m->un.value.level[0] * 100 / AUDIO_MAX_GAIN;
71 + mvprintw(3,COLS/2-1,"-");
72 + mvprintw(LINES-7,COLS/2-1,"-");
73 + mvprintw((LINES-8)-(vol*(LINES-12)/100),COLS/2-1,"*");
81 if ((mixernum=open("/dev/mixer", O_RDWR)) < 0) {
92 * Although I hate users in general, we should probably do it.
94 ****************************************************************************/
95 +#if defined(__NetBSD__)
99 + mvprintw((LINES-8)-(vol*(LINES-12)/100),COLS/2-1," ");
103 + m = &values[device_id];
104 + ioctl(mixernum, AUDIO_MIXER_WRITE, m);
105 + m->un.value.level[0] = m->un.value.level[1] = vol * AUDIO_MAX_GAIN / 100;
106 + mvprintw((LINES-8)-(vol*(LINES-12)/100), COLS/2-1, "*");
121 /****************************************************************************
122 * It's too loud junior, turn it down!
124 ****************************************************************************/
125 +#if defined(__NetBSD__)
127 +extern void voldown()
129 + mvprintw((LINES-8)-(vol*(LINES-12)/100),COLS/2-1," ");
133 + m = &values[device_id];
134 + ioctl(mixernum, AUDIO_MIXER_WRITE, m);
135 + m->un.value.level[0] = m->un.value.level[1] = vol * AUDIO_MAX_GAIN / 100;
136 + mvprintw((LINES-8)-(vol*(LINES-12)/100), COLS/2-1, "*");
142 extern void voldown()
152 \ No newline at end of file