Lines 1-146
Link Here
|
1 |
*** mix.c.orig Fri Apr 20 11:52:28 2001 |
|
|
2 |
--- mix.c Sun Jul 22 12:19:34 2001 |
3 |
*************** |
4 |
*** 20,26 **** |
5 |
--- 20,28 ---- |
6 |
#include <stdlib.h> |
7 |
#include <string.h> |
8 |
#include <ctype.h> |
9 |
+ #ifdef linux |
10 |
#include <getopt.h> |
11 |
+ #endif |
12 |
#include <time.h> |
13 |
#include <unistd.h> |
14 |
#include <fcntl.h> |
15 |
*************** |
16 |
*** 887,899 **** |
17 |
#ifdef CUSTOM |
18 |
#undef SOUND_DEVICE_NAMES |
19 |
|
20 |
! #define SOUND_DEVICE_NAMES {"Master Volume", "Bass", "Treble", "FM Synth Volume", "PCM - Wave Volume", "PC Speaker", "Line In Level", \ |
21 |
! "Microphone Level", "CD Input Volume", "Mixer Level", "PCM2 - Wave Volume", "Recording Volume", "Input Gain", "Output Gain", \ |
22 |
! "Line1 Input", "Line2 Input", "Line3 Input", "Digital 1", "Digital 2", "Digital 3", \ |
23 |
! "Phone Input", "Phone Output", "Video Card Volume", "Radio Card volume", "Monitor Volume"} |
24 |
#endif |
25 |
char *names[] = SOUND_DEVICE_NAMES; |
26 |
struct mixer_info mixer_info; |
27 |
|
28 |
if ((mixer_fd = open(value("mixerdev"), O_RDWR)) == -1) { |
29 |
printf("error: cannot open mixer device %s\n", value("mixerdev")); |
30 |
--- 889,903 ---- |
31 |
#ifdef CUSTOM |
32 |
#undef SOUND_DEVICE_NAMES |
33 |
|
34 |
! #define SOUND_DEVICE_NAMES {" Master Volume", " Bass", " Treble", " Synth Volume", " Wave Volume", " PC Speaker", " Line In Level", \ |
35 |
! " Microphone Level", " CD Volume", " Mixer Level", " Wave 2 Volume", " Recording Volume", " Input Gain", " Output Gain", \ |
36 |
! " Line1 Input", " Line2 Input", " Line3 Input", " Digital 1", " Digital 2", " Digital 3", \ |
37 |
! " Phone Input", " Phone Output", " Video Card Volume", " Radio Card Volume", " Monitor Volume"} |
38 |
#endif |
39 |
char *names[] = SOUND_DEVICE_NAMES; |
40 |
+ #ifndef __FreeBSD__ |
41 |
struct mixer_info mixer_info; |
42 |
+ #endif |
43 |
|
44 |
if ((mixer_fd = open(value("mixerdev"), O_RDWR)) == -1) { |
45 |
printf("error: cannot open mixer device %s\n", value("mixerdev")); |
46 |
*************** |
47 |
*** 921,932 **** |
48 |
exit(1); |
49 |
} |
50 |
|
51 |
if (ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info) == -1) { |
52 |
printf("error: cannot get mixer info off mixer\n"); |
53 |
exit(1); |
54 |
} |
55 |
- |
56 |
printf("%s (%s) [", mixer_info.name, mixer_info.id); |
57 |
for (count = 0; count < SOUND_MIXER_NRDEVICES; count++) { |
58 |
if ((1 << count) & devmask) { |
59 |
strcpy(mixer[nchannels].name, names[count]); |
60 |
--- 925,940 ---- |
61 |
exit(1); |
62 |
} |
63 |
|
64 |
+ #ifdef __FreeBSD__ |
65 |
+ printf("["); |
66 |
+ #else |
67 |
if (ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info) == -1) { |
68 |
printf("error: cannot get mixer info off mixer\n"); |
69 |
exit(1); |
70 |
} |
71 |
printf("%s (%s) [", mixer_info.name, mixer_info.id); |
72 |
+ #endif |
73 |
+ |
74 |
for (count = 0; count < SOUND_MIXER_NRDEVICES; count++) { |
75 |
if ((1 << count) & devmask) { |
76 |
strcpy(mixer[nchannels].name, names[count]); |
77 |
*************** |
78 |
*** 946,951 **** |
79 |
--- 954,960 ---- |
80 |
printf("0"); |
81 |
} |
82 |
} |
83 |
+ |
84 |
printf("]\n"); |
85 |
} |
86 |
|
87 |
*************** |
88 |
*** 953,971 **** |
89 |
{ |
90 |
int i; |
91 |
int left, right, foo; |
92 |
int retry = 3; |
93 |
int stat = 1; |
94 |
struct mixer_info mixer_info; |
95 |
static int modify_counter; |
96 |
- static Mixer old_mix[SOUND_MIXER_NRDEVICES]; |
97 |
|
98 |
/* check for possible failure here - happens with older kernels */ |
99 |
if (ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info)) { |
100 |
while (retry-- && stat) |
101 |
stat = ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info); |
102 |
} |
103 |
|
104 |
! if (mixer_info.modify_counter != modify_counter) { |
105 |
i = 0; |
106 |
/* this happens if mixer was changed by another program, |
107 |
* so we need to update the values. We do not know, under OSS, |
108 |
--- 962,987 ---- |
109 |
{ |
110 |
int i; |
111 |
int left, right, foo; |
112 |
+ char doupdate = 0; |
113 |
+ static Mixer old_mix[SOUND_MIXER_NRDEVICES]; |
114 |
+ #ifndef __FreeBSD__ |
115 |
int retry = 3; |
116 |
int stat = 1; |
117 |
struct mixer_info mixer_info; |
118 |
static int modify_counter; |
119 |
|
120 |
/* check for possible failure here - happens with older kernels */ |
121 |
if (ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info)) { |
122 |
while (retry-- && stat) |
123 |
stat = ioctl(mixer_fd, SOUND_MIXER_INFO, &mixer_info); |
124 |
} |
125 |
+ doupdate = mixer_info.modify_counter != modify_counter; |
126 |
+ #else |
127 |
+ /* clearly something better would be nice, but hey, it works! */ |
128 |
+ doupdate = 1; |
129 |
+ #endif |
130 |
|
131 |
! if (doupdate) { |
132 |
i = 0; |
133 |
/* this happens if mixer was changed by another program, |
134 |
* so we need to update the values. We do not know, under OSS, |
135 |
*************** |
136 |
*** 1022,1028 **** |
137 |
--- 1038,1046 ---- |
138 |
} |
139 |
} |
140 |
} |
141 |
+ #ifndef __FreeBSD__ |
142 |
modify_counter = mixer_info.modify_counter; |
143 |
+ #endif |
144 |
memcpy(old_mix, mixer, sizeof(mixer)); |
145 |
} |
146 |
|