1 #define SUBSYSTEM APPLICATION_EXEC ": "
2 
3 #if defined(HAVE_PATHS_H) && defined(_PATH_DEV)
4 #define MIXER_NAME_DIR _PATH_DEV
5 #else
6 #define MIXER_NAME_DIR "/dev/"
7 #endif
8 #define MIXER_NAME_PRE "mixer"
9 
10 struct mixer_card {
11 	int mixer;								/* Mixer id */
12 	int card;								/* Soundcard id for this mixer*/
13 
14 	char name[16 + 1];							/* Mixer node, size from soundcard.h */
15 
16 	char name_s[16 + 1];							/* Soundcard short name, size from soundcard.h */
17 	char name_l[128 + 1];							/* Soundcard long name, size from soundcard.h */
18 };
19 
20 static int mix_h = 0;								/* Selected mixer handle */
21 
22 static int mixer_card_a = 0;							/* Number of audios available */
23 static int mixer_card_c = 0;							/* Number of mixers available */
24 static int mixer_card_d = 0;							/* Number of mixer currently selected */
25 
26 static unsigned int mixer_card_r = 0;						/* Recording source currently selected */
27 
28 #if ! defined(PROG_DISABLE_AUDIO)
29 static unsigned int mix_tst_w = 0;						/* White noise track handle */
30 #endif
31 
32 static struct mixer_card *mixer_card_t = NULL;
33 
34 static struct w_stack *win_s = NULL;
35 
36 static struct pixel_rgba_8 label_c;
37 
38 #if defined(__FreeBSD__)
39 static const char *mixer_n[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
40 
41 #define MIXER_CAP_DEV 0
42 #define MIXER_CAP_REC 1
43 #define MIXER_CAP_SRC 2
44 
45 #define MIXER_CAP_CMD 3
46 
47 static const unsigned long mixer_c[MIXER_CAP_CMD] = {
48 	SOUND_MIXER_READ_DEVMASK,
49 	SOUND_MIXER_READ_RECMASK,
50 	SOUND_MIXER_READ_RECSRC
51 };
52 
53 static int mixer_r[MIXER_CAP_CMD] = {
54 	0, 0, 0
55 };
56 #endif
57 
58 struct c_c {
59 	int i;									/* Device order number in mixer_n[] */
60 	int r;									/* Device is recording source or not */
61 
62 	size_t t;								/* Device name length in bytes */
63 
64 	char *c;								/* Device name */
65 	char *n;								/* Device human readable name */
66 
67 	int x, y;								/* Device control position in window */
68 };
69 
70 static struct c_c c_c_lab = {
71 	0, 0, 0, NULL, NULL, 30, 596
72 };
73 
74 static struct c_c c_c_sel = {
75 	0, 0, 0, NULL, "Mixer", 1046, 80
76 };
77 
78 static struct c_c c_c_rec = {
79 	0, 0, 0, NULL, "Record", 66, 80
80 };
81 
82 static struct c_c c_c_nse[] = {
83 	{ 0, 0, 0, NULL, "Noise Vol", 1062, 262 },
84 	{ 0, 0, 0, NULL, "Noise Pan", 1062, 444 },
85 	{ 0, 0, 0, NULL, "White Noise", 1078, 548 }
86 };
87 
88 static struct c_c c_c_mix[] = {
89 	{ 0, 0, 7, "monitor", "Monitor", 40, 270 },
90 	{ 0, 0, 4, "line", "Line", 140, 270 },
91 	{ 0, 0, 3, "mic", "Mic", 240, 270 },
92 	{ 0, 0, 3, "mix", "Mix", 340, 270 },
93 	{ 0, 0, 3, "rec", "Rec", 440, 270 },
94 	{ 0, 0, 4, "pcm2", "Aux", 540, 270 },
95 	{ 0, 0, 3, "pcm", "PCM", 640, 270 },
96 	{ 0, 0, 3, "vol", "Volume", 740, 270 },
97 
98 	{ 0, 0, 0, NULL, NULL, 0, 0 }
99 };
100 
101 static struct c_c c_c_ext[] = {
102 	{ 0, 0, 4, "bass", "Bass", 244, 80 },
103 	{ 0, 0, 6, "treble", "Treble", 404, 80 },
104 	{ 0, 0, 5, "igain", "In Gain", 564, 80 },
105 	{ 0, 0, 5, "ogain", "Out Gain", 724, 80 },
106 	{ 0, 0, 4, "dig1", "Digital A", 884, 80 },
107 	{ 0, 0, 4, "dig2", "Digital B", 884, 262 },
108 	{ 0, 0, 4, "dig3", "Digital C", 884, 444 },
109 
110 	{ 0, 0, 0, NULL, NULL, 0, 0 }
111 };
112 
113 #if ! defined(PROG_DISABLE_AUDIO)
114 static struct c_c c_c_tst[] = {
115 	{ 0, 0, 5, "white", "White", 0, 0 },
116 
117 	{ 0, 0, 0, NULL, NULL, 0, 0 }
118 };
119 #endif
120 
121 void bsd_mixer_sel(char *, unsigned int, unsigned int);
122 
123 static int bsd_prepare_op(struct w_stack *, int);
124 static void bsd_prepare_at(struct w_stack *, int);
125 static void bsd_prepare_sd(struct w_stack *, unsigned int);
126 
127 static int bsd_prepare_mixer_lab(struct w_stack *, struct pixel_rgba_8 *);
128 static int bsd_prepare_mixer_sel(struct w_stack *, struct pixel_rgba_8 *);
129 static int bsd_prepare_mixer_mix(int, struct w_stack *, struct pixel_rgba_8 *);
130 #if defined(__FreeBSD__)
131 static int bsd_prepare_mixer_mix_op(struct w_stack *, struct pixel_rgba_8 *, char *, int, int, int, int, int, unsigned int);
132 static int bsd_prepare_mixer_ext_op(struct w_stack *, struct pixel_rgba_8 *, char *, int, int, int, int, int, unsigned int);
133 #endif
134 static int bsd_prepare_mixer_ext(int, struct w_stack *, struct pixel_rgba_8 *);
135 static int bsd_prepare_mixer_rec(struct w_stack *, struct pixel_rgba_8 *);
136 static int bsd_prepare_mixer_tst(struct w_stack *, struct pixel_rgba_8 *);
137 #if ! defined(PROG_DISABLE_AUDIO)
138 static int bsd_prepare_mixer_tst_kn(struct w_stack *, struct pixel_rgba_8 *);
139 static int bsd_prepare_mixer_tst_bt(struct w_stack *, struct pixel_rgba_8 *);
140 #endif
141 
142 static void bsd_update_mixer_lab(struct w_stack *);
143 static void bsd_update_mixer_mix(int, struct w_stack *);
144 static void bsd_update_mixer_ext(int, struct w_stack *);
145 static void bsd_update_mixer_rec(struct w_stack *);
146 
147 static void bsd_mixer_mix_monitor(int, unsigned int, unsigned int);
148 static void bsd_mixer_mix_line(int, unsigned int, unsigned int);
149 static void bsd_mixer_mix_mic(int, unsigned int, unsigned int);
150 static void bsd_mixer_mix_mix(int, unsigned int, unsigned int);
151 static void bsd_mixer_mix_rec(int, unsigned int, unsigned int);
152 static void bsd_mixer_mix_aux(int, unsigned int, unsigned int);
153 static void bsd_mixer_mix_pcm(int, unsigned int, unsigned int);
154 static void bsd_mixer_mix_vol(int, unsigned int, unsigned int);
155 static void bsd_mixer_mix_op(char *, char *, unsigned int, unsigned int, struct c_c *, const void *[]);
156 
157 static void bsd_mixer_ext_bass(int, unsigned int, unsigned int);
158 static void bsd_mixer_ext_treble(int, unsigned int, unsigned int);
159 static void bsd_mixer_ext_igain(int, unsigned int, unsigned int);
160 static void bsd_mixer_ext_ogain(int, unsigned int, unsigned int);
161 static void bsd_mixer_ext_dig1(int, unsigned int, unsigned int);
162 static void bsd_mixer_ext_dig2(int, unsigned int, unsigned int);
163 static void bsd_mixer_ext_dig3(int, unsigned int, unsigned int);
164 
165 #if ! defined(PROG_DISABLE_AUDIO)
166 static void bsd_mixer_tst_white(int, unsigned int, unsigned int);
167 static void bsd_mixer_tst_op(unsigned int);
168 static float bsd_mixer_tst_at(char *, unsigned int, unsigned int, float, float);
169 #endif
170 
171 static int bsd_open_mixer(char *);
172 #if defined(__FreeBSD__)
173 static int bsd_open_mixer_freebsd(int);
174 #endif
175 static void bsd_mixer_er(char *);
176 static void bsd_close(int);
177 
178 static int bsd_list(void);
179 #if defined(__FreeBSD__)
180 static int bsd_list_freebsd(void);
181 static int bsd_list_freebsd_op(int);
182 #endif
183 static int bsd_list_op(int);
184 static void bsd_list_free(void);
185 
186 static int bsd_get_p_level(int, int, int *);
187 static int bsd_set_p_level(int, int, int, int);
188 static int bsd_get_r_source(int);
189 
190 /* worker_play.c */
191 #if ! defined(PROG_DISABLE_AUDIO)
192 void worker_play(void *);
193 #endif
194