ctl.c revision 1.22 1 1.22 mrg /* $NetBSD: ctl.c,v 1.22 1999/03/26 14:02:41 mrg Exp $ */
2 1.1 augustss
3 1.1 augustss /*
4 1.1 augustss * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 1.1 augustss * All rights reserved.
6 1.1 augustss *
7 1.21 augustss * This code is derived from software contributed to The NetBSD Foundation
8 1.21 augustss * by Lennart Augustsson (augustss (at) netbsd.org).
9 1.1 augustss *
10 1.1 augustss * Redistribution and use in source and binary forms, with or without
11 1.1 augustss * modification, are permitted provided that the following conditions
12 1.1 augustss * are met:
13 1.1 augustss * 1. Redistributions of source code must retain the above copyright
14 1.1 augustss * notice, this list of conditions and the following disclaimer.
15 1.1 augustss * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 augustss * notice, this list of conditions and the following disclaimer in the
17 1.1 augustss * documentation and/or other materials provided with the distribution.
18 1.1 augustss * 3. All advertising materials mentioning features or use of this software
19 1.1 augustss * must display the following acknowledgement:
20 1.1 augustss * This product includes software developed by the NetBSD
21 1.1 augustss * Foundation, Inc. and its contributors.
22 1.1 augustss * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 augustss * contributors may be used to endorse or promote products derived
24 1.1 augustss * from this software without specific prior written permission.
25 1.1 augustss *
26 1.1 augustss * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 augustss * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 augustss * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.10 jtc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.10 jtc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 augustss * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 augustss * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 augustss * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 augustss * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 augustss * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 augustss * POSSIBILITY OF SUCH DAMAGE.
37 1.1 augustss */
38 1.1 augustss
39 1.1 augustss #include <sys/types.h>
40 1.2 augustss #include <sys/stat.h>
41 1.1 augustss #include <sys/ioctl.h>
42 1.1 augustss #include <sys/audioio.h>
43 1.1 augustss
44 1.22 mrg #include <err.h>
45 1.22 mrg #include <fcntl.h>
46 1.22 mrg #include <stdio.h>
47 1.22 mrg #include <stdlib.h>
48 1.22 mrg #include <string.h>
49 1.22 mrg #include <unistd.h>
50 1.22 mrg
51 1.22 mrg #include <paths.h>
52 1.22 mrg
53 1.22 mrg #include "libaudio.h"
54 1.22 mrg
55 1.22 mrg /* yeah, for now ... */
56 1.22 mrg #if 1
57 1.22 mrg #define _PATH_OAUDIO "/dev/audio"
58 1.22 mrg #define _PATH_OAUDIOCTL "/dev/audioctl"
59 1.22 mrg #endif
60 1.19 augustss
61 1.9 augustss struct field *findfield __P((char *name));
62 1.9 augustss void prfield __P((struct field *p, char *sep));
63 1.9 augustss void rdfield __P((struct field *p, char *q));
64 1.9 augustss void getinfo __P((int fd));
65 1.22 mrg void audioctl_write __P((int, int, char *[]));
66 1.9 augustss void usage __P((void));
67 1.9 augustss int main __P((int argc, char **argv));
68 1.9 augustss
69 1.1 augustss FILE *out = stdout;
70 1.1 augustss
71 1.1 augustss char *prog;
72 1.1 augustss
73 1.1 augustss audio_device_t adev;
74 1.1 augustss
75 1.1 augustss audio_info_t info;
76 1.1 augustss
77 1.1 augustss char encbuf[1000];
78 1.1 augustss
79 1.6 augustss int properties, fullduplex, rerror;
80 1.1 augustss
81 1.1 augustss struct field {
82 1.1 augustss char *name;
83 1.1 augustss void *valp;
84 1.1 augustss int format;
85 1.1 augustss #define STRING 1
86 1.1 augustss #define INT 2
87 1.1 augustss #define UINT 3
88 1.1 augustss #define P_R 4
89 1.18 mrg #define ULONG 5 /* XXX obsolete now */
90 1.1 augustss #define UCHAR 6
91 1.1 augustss #define ENC 7
92 1.6 augustss #define PROPS 8
93 1.12 augustss #define XINT 9
94 1.17 mycroft #define FORMAT 10
95 1.2 augustss char flags;
96 1.2 augustss #define READONLY 1
97 1.2 augustss #define ALIAS 2
98 1.2 augustss #define SET 4
99 1.1 augustss } fields[] = {
100 1.11 augustss { "name", &adev.name, STRING, READONLY },
101 1.11 augustss { "version", &adev.version, STRING, READONLY },
102 1.11 augustss { "config", &adev.config, STRING, READONLY },
103 1.11 augustss { "encodings", encbuf, STRING, READONLY },
104 1.11 augustss { "properties", &properties, PROPS, READONLY },
105 1.15 augustss { "full_duplex", &fullduplex, UINT, 0 },
106 1.15 augustss { "fullduplex", &fullduplex, UINT, 0 },
107 1.11 augustss { "blocksize", &info.blocksize, UINT, 0 },
108 1.11 augustss { "hiwat", &info.hiwat, UINT, 0 },
109 1.11 augustss { "lowat", &info.lowat, UINT, 0 },
110 1.12 augustss { "monitor_gain", &info.monitor_gain, UINT, 0 },
111 1.11 augustss { "mode", &info.mode, P_R, READONLY },
112 1.17 mycroft { "play", &info.play, FORMAT, ALIAS },
113 1.11 augustss { "play.rate", &info.play.sample_rate, UINT, 0 },
114 1.11 augustss { "play.sample_rate", &info.play.sample_rate, UINT, ALIAS },
115 1.11 augustss { "play.channels", &info.play.channels, UINT, 0 },
116 1.11 augustss { "play.precision", &info.play.precision, UINT, 0 },
117 1.11 augustss { "play.encoding", &info.play.encoding, ENC, 0 },
118 1.11 augustss { "play.gain", &info.play.gain, UINT, 0 },
119 1.12 augustss { "play.balance", &info.play.balance, UCHAR, 0 },
120 1.12 augustss { "play.port", &info.play.port, XINT, 0 },
121 1.12 augustss { "play.avail_ports", &info.play.avail_ports, XINT, 0 },
122 1.18 mrg { "play.seek", &info.play.seek, UINT, READONLY },
123 1.11 augustss { "play.samples", &info.play.samples, UINT, READONLY },
124 1.11 augustss { "play.eof", &info.play.eof, UINT, READONLY },
125 1.11 augustss { "play.pause", &info.play.pause, UCHAR, 0 },
126 1.11 augustss { "play.error", &info.play.error, UCHAR, READONLY },
127 1.11 augustss { "play.waiting", &info.play.waiting, UCHAR, READONLY },
128 1.11 augustss { "play.open", &info.play.open, UCHAR, READONLY },
129 1.11 augustss { "play.active", &info.play.active, UCHAR, READONLY },
130 1.12 augustss { "play.buffer_size", &info.play.buffer_size, UINT, 0 },
131 1.17 mycroft { "record", &info.record, FORMAT, ALIAS },
132 1.11 augustss { "record.rate", &info.record.sample_rate,UINT, 0 },
133 1.11 augustss { "record.sample_rate", &info.record.sample_rate,UINT, ALIAS },
134 1.11 augustss { "record.channels", &info.record.channels, UINT, 0 },
135 1.11 augustss { "record.precision", &info.record.precision, UINT, 0 },
136 1.11 augustss { "record.encoding", &info.record.encoding, ENC, 0 },
137 1.11 augustss { "record.gain", &info.record.gain, UINT, 0 },
138 1.12 augustss { "record.balance", &info.record.balance, UCHAR, 0 },
139 1.12 augustss { "record.port", &info.record.port, XINT, 0 },
140 1.12 augustss { "record.avail_ports", &info.record.avail_ports,XINT, 0 },
141 1.18 mrg { "record.seek", &info.record.seek, UINT, READONLY },
142 1.11 augustss { "record.samples", &info.record.samples, UINT, READONLY },
143 1.11 augustss { "record.eof", &info.record.eof, UINT, READONLY },
144 1.11 augustss { "record.pause", &info.record.pause, UCHAR, 0 },
145 1.11 augustss { "record.error", &info.record.error, UCHAR, READONLY },
146 1.11 augustss { "record.waiting", &info.record.waiting, UCHAR, READONLY },
147 1.11 augustss { "record.open", &info.record.open, UCHAR, READONLY },
148 1.11 augustss { "record.active", &info.record.active, UCHAR, READONLY },
149 1.12 augustss { "record.buffer_size", &info.record.buffer_size,UINT, 0 },
150 1.11 augustss { "record.errors", &rerror, INT, READONLY },
151 1.11 augustss { 0 }
152 1.1 augustss };
153 1.1 augustss
154 1.11 augustss static struct {
155 1.11 augustss char *name;
156 1.11 augustss u_int prop;
157 1.11 augustss } props[] = {
158 1.11 augustss { "full_duplex", AUDIO_PROP_FULLDUPLEX },
159 1.11 augustss { "mmap", AUDIO_PROP_MMAP },
160 1.11 augustss { "independent", AUDIO_PROP_INDEPENDENT },
161 1.11 augustss { 0 }
162 1.1 augustss };
163 1.1 augustss
164 1.1 augustss struct field *
165 1.9 augustss findfield(name)
166 1.11 augustss char *name;
167 1.1 augustss {
168 1.11 augustss int i;
169 1.22 mrg for (i = 0; fields[i].name; i++)
170 1.11 augustss if (strcmp(fields[i].name, name) == 0)
171 1.11 augustss return &fields[i];
172 1.11 augustss return 0;
173 1.1 augustss }
174 1.1 augustss
175 1.1 augustss void
176 1.9 augustss prfield(p, sep)
177 1.11 augustss struct field *p;
178 1.11 augustss char *sep;
179 1.1 augustss {
180 1.11 augustss u_int v;
181 1.22 mrg char *cm, *encstr;
182 1.11 augustss int i;
183 1.11 augustss
184 1.11 augustss if (sep)
185 1.11 augustss fprintf(out, "%s%s", p->name, sep);
186 1.11 augustss switch(p->format) {
187 1.11 augustss case STRING:
188 1.11 augustss fprintf(out, "%s", (char*)p->valp);
189 1.11 augustss break;
190 1.11 augustss case INT:
191 1.11 augustss fprintf(out, "%d", *(int*)p->valp);
192 1.11 augustss break;
193 1.11 augustss case UINT:
194 1.11 augustss fprintf(out, "%u", *(u_int*)p->valp);
195 1.11 augustss break;
196 1.12 augustss case XINT:
197 1.12 augustss fprintf(out, "0x%x", *(u_int*)p->valp);
198 1.12 augustss break;
199 1.11 augustss case UCHAR:
200 1.11 augustss fprintf(out, "%u", *(u_char*)p->valp);
201 1.11 augustss break;
202 1.11 augustss case ULONG:
203 1.11 augustss fprintf(out, "%lu", *(u_long*)p->valp);
204 1.11 augustss break;
205 1.11 augustss case P_R:
206 1.11 augustss v = *(u_int*)p->valp;
207 1.11 augustss cm = "";
208 1.11 augustss if (v & AUMODE_PLAY) {
209 1.11 augustss if (v & AUMODE_PLAY_ALL)
210 1.11 augustss fprintf(out, "play");
211 1.11 augustss else
212 1.11 augustss fprintf(out, "playsync");
213 1.11 augustss cm = ",";
214 1.11 augustss }
215 1.11 augustss if (v & AUMODE_RECORD)
216 1.11 augustss fprintf(out, "%srecord", cm);
217 1.11 augustss break;
218 1.11 augustss case ENC:
219 1.11 augustss v = *(u_int*)p->valp;
220 1.22 mrg encstr = audio_enc_from_val(v);
221 1.22 mrg if (encstr)
222 1.22 mrg fprintf(out, "%s", encstr);
223 1.11 augustss else
224 1.11 augustss fprintf(out, "%u", v);
225 1.11 augustss break;
226 1.11 augustss case PROPS:
227 1.11 augustss v = *(u_int*)p->valp;
228 1.11 augustss for (cm = "", i = 0; props[i].name; i++) {
229 1.11 augustss if (v & props[i].prop) {
230 1.11 augustss fprintf(out, "%s%s", cm, props[i].name);
231 1.11 augustss cm = ",";
232 1.11 augustss }
233 1.11 augustss }
234 1.1 augustss break;
235 1.17 mycroft case FORMAT:
236 1.17 mycroft prfield(p + 1, 0);
237 1.17 mycroft fprintf(out, ",");
238 1.17 mycroft prfield(p + 3, 0);
239 1.17 mycroft fprintf(out, ",");
240 1.17 mycroft prfield(p + 4, 0);
241 1.17 mycroft fprintf(out, ",");
242 1.17 mycroft prfield(p + 5, 0);
243 1.17 mycroft break;
244 1.11 augustss default:
245 1.12 augustss errx(1, "Invalid print format.");
246 1.6 augustss }
247 1.2 augustss }
248 1.2 augustss
249 1.2 augustss void
250 1.9 augustss rdfield(p, q)
251 1.11 augustss struct field *p;
252 1.11 augustss char *q;
253 1.2 augustss {
254 1.22 mrg int enc;
255 1.12 augustss u_int u;
256 1.17 mycroft char *s;
257 1.2 augustss
258 1.11 augustss switch(p->format) {
259 1.11 augustss case UINT:
260 1.11 augustss if (sscanf(q, "%u", (unsigned int *)p->valp) != 1)
261 1.17 mycroft errx(1, "Bad number: %s", q);
262 1.1 augustss break;
263 1.12 augustss case UCHAR:
264 1.12 augustss if (sscanf(q, "%u", &u) != 1)
265 1.17 mycroft errx(1, "Bad number: %s", q);
266 1.12 augustss else
267 1.12 augustss *(u_char *)p->valp = u;
268 1.12 augustss break;
269 1.12 augustss case XINT:
270 1.12 augustss if (sscanf(q, "0x%x", (unsigned int *)p->valp) != 1 &&
271 1.12 augustss sscanf(q, "%x", (unsigned int *)p->valp) != 1)
272 1.17 mycroft errx(1, "Bad number: %s", q);
273 1.12 augustss break;
274 1.11 augustss case ENC:
275 1.22 mrg enc = audio_enc_to_val(q);
276 1.22 mrg if (enc >= 0)
277 1.22 mrg *(u_int*)p->valp = enc;
278 1.11 augustss else
279 1.17 mycroft errx(1, "Unknown encoding: %s", q);
280 1.17 mycroft break;
281 1.17 mycroft case FORMAT:
282 1.17 mycroft s = strsep(&q, ",");
283 1.17 mycroft if (s)
284 1.17 mycroft rdfield(p + 1, s);
285 1.17 mycroft s = strsep(&q, ",");
286 1.17 mycroft if (s)
287 1.17 mycroft rdfield(p + 3, s);
288 1.17 mycroft s = strsep(&q, ",");
289 1.17 mycroft if (s)
290 1.17 mycroft rdfield(p + 4, s);
291 1.17 mycroft s = strsep(&q, ",");
292 1.17 mycroft if (s)
293 1.17 mycroft rdfield(p + 5, s);
294 1.17 mycroft if (!s || q)
295 1.17 mycroft errx(1, "Bad format");
296 1.11 augustss break;
297 1.11 augustss default:
298 1.12 augustss errx(1, "Invalid read format.");
299 1.11 augustss }
300 1.11 augustss p->flags |= SET;
301 1.1 augustss }
302 1.1 augustss
303 1.1 augustss void
304 1.9 augustss getinfo(fd)
305 1.11 augustss int fd;
306 1.1 augustss {
307 1.11 augustss int pos, i;
308 1.1 augustss
309 1.11 augustss if (ioctl(fd, AUDIO_GETDEV, &adev) < 0)
310 1.11 augustss err(1, "AUDIO_GETDEV");
311 1.16 mycroft for (pos = 0, i = 0; ; i++) {
312 1.11 augustss audio_encoding_t enc;
313 1.11 augustss enc.index = i;
314 1.11 augustss if (ioctl(fd, AUDIO_GETENC, &enc) < 0)
315 1.11 augustss break;
316 1.16 mycroft if (pos >= sizeof(encbuf)-1)
317 1.16 mycroft break;
318 1.11 augustss if (pos)
319 1.11 augustss encbuf[pos++] = ',';
320 1.16 mycroft if (pos >= sizeof(encbuf)-1)
321 1.16 mycroft break;
322 1.16 mycroft pos += snprintf(encbuf+pos, sizeof(encbuf)-pos, "%s:%d%s",
323 1.16 mycroft enc.name, enc.precision,
324 1.11 augustss enc.flags & AUDIO_ENCODINGFLAG_EMULATED ? "*" : "");
325 1.11 augustss }
326 1.11 augustss if (ioctl(fd, AUDIO_GETFD, &fullduplex) < 0)
327 1.11 augustss err(1, "AUDIO_GETFD");
328 1.11 augustss if (ioctl(fd, AUDIO_GETPROPS, &properties) < 0)
329 1.11 augustss err(1, "AUDIO_GETPROPS");
330 1.11 augustss if (ioctl(fd, AUDIO_RERROR, &rerror) < 0)
331 1.11 augustss err(1, "AUDIO_RERROR");
332 1.11 augustss if (ioctl(fd, AUDIO_GETINFO, &info) < 0)
333 1.11 augustss err(1, "AUDIO_GETINFO");
334 1.2 augustss }
335 1.2 augustss
336 1.2 augustss void
337 1.9 augustss usage()
338 1.2 augustss {
339 1.22 mrg
340 1.22 mrg fprintf(stderr, "Usage: %s [-f file] [-n] name ...\n", prog);
341 1.22 mrg fprintf(stderr, "Usage: %s [-f file] [-n] -w name=value ...\n", prog);
342 1.22 mrg fprintf(stderr, "Usage: %s [-f file] [-n] -a\n", prog);
343 1.11 augustss exit(1);
344 1.1 augustss }
345 1.1 augustss
346 1.9 augustss int
347 1.9 augustss main(argc, argv)
348 1.11 augustss int argc;
349 1.11 augustss char **argv;
350 1.1 augustss {
351 1.11 augustss int fd, i, ch;
352 1.11 augustss int aflag = 0, wflag = 0;
353 1.11 augustss struct stat dstat, ostat;
354 1.16 mycroft const char *file;
355 1.11 augustss char *sep = "=";
356 1.22 mrg extern char *__progname;
357 1.2 augustss
358 1.14 augustss file = getenv("AUDIOCTLDEVICE");
359 1.13 augustss if (file == 0)
360 1.22 mrg file = _PATH_AUDIOCTL;
361 1.13 augustss
362 1.22 mrg prog = __progname;
363 1.2 augustss
364 1.11 augustss while ((ch = getopt(argc, argv, "af:nw")) != -1) {
365 1.11 augustss switch(ch) {
366 1.11 augustss case 'a':
367 1.11 augustss aflag++;
368 1.11 augustss break;
369 1.11 augustss case 'w':
370 1.11 augustss wflag++;
371 1.11 augustss break;
372 1.11 augustss case 'n':
373 1.11 augustss sep = 0;
374 1.11 augustss break;
375 1.11 augustss case 'f':
376 1.11 augustss file = optarg;
377 1.11 augustss break;
378 1.11 augustss case '?':
379 1.11 augustss default:
380 1.11 augustss usage();
381 1.11 augustss }
382 1.1 augustss }
383 1.11 augustss argc -= optind;
384 1.11 augustss argv += optind;
385 1.1 augustss
386 1.11 augustss fd = open(file, O_WRONLY);
387 1.11 augustss if (fd < 0)
388 1.11 augustss fd = open(file, O_RDONLY);
389 1.22 mrg #ifdef _PATH_OAUDIOCTL
390 1.19 augustss /* Allow the non-unit device to be used. */
391 1.22 mrg if (fd < 0 && file == _PATH_AUDIOCTL) {
392 1.22 mrg file = _PATH_OAUDIOCTL;
393 1.19 augustss fd = open(file, O_WRONLY);
394 1.19 augustss if (fd < 0)
395 1.19 augustss fd = open(file, O_RDONLY);
396 1.19 augustss }
397 1.19 augustss #endif
398 1.11 augustss if (fd < 0)
399 1.11 augustss err(1, "%s", file);
400 1.2 augustss
401 1.11 augustss /* Check if stdout is the same device as the audio device. */
402 1.11 augustss if (fstat(fd, &dstat) < 0)
403 1.22 mrg err(1, "fstat audioctl");
404 1.11 augustss if (fstat(STDOUT_FILENO, &ostat) < 0)
405 1.9 augustss err(1, "fstat stdout");
406 1.11 augustss if (S_ISCHR(dstat.st_mode) && S_ISCHR(ostat.st_mode) &&
407 1.11 augustss major(dstat.st_dev) == major(ostat.st_dev) &&
408 1.11 augustss minor(dstat.st_dev) == minor(ostat.st_dev))
409 1.11 augustss /* We can't write to stdout so use stderr */
410 1.11 augustss out = stderr;
411 1.11 augustss
412 1.11 augustss if (!wflag)
413 1.2 augustss getinfo(fd);
414 1.11 augustss
415 1.11 augustss if (argc == 0 && aflag && !wflag) {
416 1.22 mrg for (i = 0; fields[i].name; i++) {
417 1.11 augustss if (!(fields[i].flags & ALIAS)) {
418 1.11 augustss prfield(&fields[i], sep);
419 1.11 augustss fprintf(out, "\n");
420 1.11 augustss }
421 1.1 augustss }
422 1.11 augustss } else if (argc > 0 && !aflag) {
423 1.11 augustss if (wflag) {
424 1.22 mrg audioctl_write(fd, argc, argv);
425 1.11 augustss if (sep) {
426 1.11 augustss getinfo(fd);
427 1.22 mrg for (i = 0; fields[i].name; i++) {
428 1.11 augustss if (fields[i].flags & SET) {
429 1.11 augustss fprintf(out, "%s: -> ", fields[i].name);
430 1.11 augustss prfield(&fields[i], 0);
431 1.11 augustss fprintf(out, "\n");
432 1.11 augustss }
433 1.11 augustss }
434 1.11 augustss }
435 1.1 augustss } else {
436 1.22 mrg struct field *p;
437 1.22 mrg while (argc--) {
438 1.11 augustss p = findfield(*argv);
439 1.11 augustss if (p == 0) {
440 1.11 augustss if (strchr(*argv, '='))
441 1.11 augustss warnx("field %s does not exist (use -w to set a variable)", *argv);
442 1.11 augustss else
443 1.11 augustss warnx("field %s does not exist", *argv);
444 1.11 augustss } else {
445 1.11 augustss prfield(p, sep);
446 1.11 augustss fprintf(out, "\n");
447 1.11 augustss }
448 1.11 augustss argv++;
449 1.11 augustss }
450 1.1 augustss }
451 1.11 augustss } else
452 1.11 augustss usage();
453 1.11 augustss exit(0);
454 1.22 mrg }
455 1.22 mrg
456 1.22 mrg void
457 1.22 mrg audioctl_write(fd, argc, argv)
458 1.22 mrg int fd;
459 1.22 mrg int argc;
460 1.22 mrg char *argv[];
461 1.22 mrg {
462 1.22 mrg struct field *p;
463 1.22 mrg
464 1.22 mrg AUDIO_INITINFO(&info);
465 1.22 mrg while (argc--) {
466 1.22 mrg char *q;
467 1.22 mrg
468 1.22 mrg q = strchr(*argv, '=');
469 1.22 mrg if (q) {
470 1.22 mrg *q++ = 0;
471 1.22 mrg p = findfield(*argv);
472 1.22 mrg if (p == 0)
473 1.22 mrg warnx("field `%s' does not exist", *argv);
474 1.22 mrg else {
475 1.22 mrg if (p->flags & READONLY)
476 1.22 mrg warnx("`%s' is read only", *argv);
477 1.22 mrg else {
478 1.22 mrg rdfield(p, q);
479 1.22 mrg if (p->valp == &fullduplex)
480 1.22 mrg if (ioctl(fd, AUDIO_SETFD, &fullduplex) < 0)
481 1.22 mrg err(1, "set failed");
482 1.22 mrg }
483 1.22 mrg }
484 1.22 mrg } else
485 1.22 mrg warnx("No `=' in %s", *argv);
486 1.22 mrg argv++;
487 1.22 mrg }
488 1.22 mrg if (ioctl(fd, AUDIO_SETINFO, &info) < 0)
489 1.22 mrg err(1, "set failed");
490 1.1 augustss }
491