make recording precision/encoding setting sane.

This commit is contained in:
mrg 1999-03-27 17:46:00 +00:00
parent a17279574e
commit eeeadf8446
3 changed files with 11 additions and 54 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: audio.c,v 1.3 1999/03/27 05:14:37 mrg Exp $ */
/* $NetBSD: audio.c,v 1.4 1999/03/27 17:46:00 mrg Exp $ */
/*
* Copyright (c) 1999 Matthew R. Green
@ -97,43 +97,6 @@ audio_enc_to_val(enc)
return (-1);
}
int
audio_parse_encoding(encoding_str, fd, encp, precp)
char *encoding_str;
int fd;
int *encp;
int *precp;
{
int i, prec = 0;
char *colon, *star;
colon = strchr(encoding_str, ':');
if (colon) {
*colon++ = '\0';
if (*colon)
prec = atoi(colon);
}
star = strrchr(encoding_str, '*');
if (star)
*star = '\0';
for (i = 0; ; i++) {
audio_encoding_t enc;
enc.index = i;
if (ioctl(fd, AUDIO_GETENC, &enc) < 0)
break;
if (strcasecmp(enc.name, encoding_str) == 0 &&
(prec == 0 || prec == enc.precision)) {
*encp = enc.encoding;
*precp = enc.precision;
return (0);
}
}
return (1);
}
/*
* SunOS/NeXT .au format helpers
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: libaudio.h,v 1.2 1999/03/26 15:46:22 mrg Exp $ */
/* $NetBSD: libaudio.h,v 1.3 1999/03/27 17:46:00 mrg Exp $ */
/*
* Copyright (c) 1999 Matthew R. Green
@ -142,8 +142,6 @@ size_t audio_parse_wav_hdr __P((void *, size_t, int *, int *, int *, int *));
/* and something to get a string associated with this error */
const char *audio_errstring __P((int));
int audio_parse_encoding __P((char *, int, int *, int *));
/*
* generic routines?
*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: record.c,v 1.2 1999/03/26 15:46:22 mrg Exp $ */
/* $NetBSD: record.c,v 1.3 1999/03/27 17:46:00 mrg Exp $ */
/*
* Copyright (c) 1999 Matthew R. Green
@ -227,21 +227,17 @@ main(argc, argv)
info.record.channels = channels;
else
channels = oinfo.record.channels;
#if 0
/* XXX ??? */
if (precision)
info.record.precision = precision;
else
precision = oinfo.record.precision;
#endif
if (encoding) {
if (audio_parse_encoding(encoding_str, ctlfd, &info.record.encoding, &info.record.precision))
if (encoding_str) {
encoding = audio_enc_to_val(encoding_str);
if (encoding == -1)
errx(1, "unknown encoding, bailing...");
} else {
encoding = oinfo.record.encoding;
precision = oinfo.record.precision;
}
if (precision)
info.record.precision = precision;
if (encoding)
info.record.encoding = encoding;
if (volume)
info.record.gain = volume;
if (port)