parent
edd394b53e
commit
e7fdf18240
|
@ -1,7 +1,8 @@
|
|||
# $NetBSD: Makefile.inc,v 1.3 2001/05/10 19:07:39 windsor Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.4 2002/01/15 23:48:51 mrg Exp $
|
||||
|
||||
.include <bsd.own.mk>
|
||||
|
||||
WARNS=3
|
||||
LIBAUDIO != cd ${.CURDIR}/../common && ${PRINTOBJDIR}
|
||||
CPPFLAGS+=-I${.CURDIR}/../common
|
||||
DPADD+= ${LIBAUDIO}/libaudio.a
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: audio.c,v 1.14 2002/01/15 08:19:37 mrg Exp $ */
|
||||
/* $NetBSD: audio.c,v 1.15 2002/01/15 23:48:52 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Matthew R. Green
|
||||
|
@ -48,7 +48,7 @@
|
|||
/* what format am i? */
|
||||
|
||||
struct {
|
||||
char *fname;
|
||||
const char *fname;
|
||||
int fno;
|
||||
} formats[] = {
|
||||
{ "sunau", AUDIO_FORMAT_SUN },
|
||||
|
@ -78,7 +78,7 @@ audio_format_from_str(str)
|
|||
|
||||
/* back and forth between encodings */
|
||||
struct {
|
||||
char *ename;
|
||||
const char *ename;
|
||||
int eno;
|
||||
} encs[] = {
|
||||
{ AudioEmulaw, AUDIO_ENCODING_ULAW },
|
||||
|
@ -105,7 +105,7 @@ struct {
|
|||
};
|
||||
|
||||
|
||||
char *
|
||||
const char *
|
||||
audio_enc_from_val(val)
|
||||
int val;
|
||||
{
|
||||
|
@ -140,7 +140,7 @@ decode_int(arg, intp)
|
|||
char *ep;
|
||||
int ret;
|
||||
|
||||
ret = strtoul(arg, &ep, 0);
|
||||
ret = (int)strtoul(arg, &ep, 0);
|
||||
|
||||
if (ep[0] == '\0') {
|
||||
*intp = ret;
|
||||
|
@ -165,13 +165,13 @@ decode_time(arg, tvp)
|
|||
s = copy;
|
||||
|
||||
/* handle [hh:]mm:ss.dd */
|
||||
if ((colon = strchr(s, ':'))) {
|
||||
if ((colon = strchr(s, ':')) != NULL) {
|
||||
*colon++ = '\0';
|
||||
decode_int(s, &first);
|
||||
tvp->tv_sec = first * 60; /* minutes */
|
||||
s = colon;
|
||||
|
||||
if ((colon = strchr(s, ':'))) {
|
||||
if ((colon = strchr(s, ':')) != NULL) {
|
||||
*colon++ = '\0';
|
||||
decode_int(s, &first);
|
||||
tvp->tv_sec *= 60;
|
||||
|
@ -179,7 +179,7 @@ decode_time(arg, tvp)
|
|||
s = colon;
|
||||
}
|
||||
}
|
||||
if ((dot = strchr(s, '.'))) {
|
||||
if ((dot = strchr(s, '.')) != NULL) {
|
||||
int i, base = 100000;
|
||||
|
||||
*dot++ = '\0';
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: libaudio.h,v 1.9 2002/01/15 08:19:37 mrg Exp $ */
|
||||
/* $NetBSD: libaudio.h,v 1.10 2002/01/15 23:48:52 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Matthew R. Green
|
||||
|
@ -89,7 +89,7 @@ typedef struct {
|
|||
#define AUDIO_FILE_ENCODING_ADPCM_G723_5 26
|
||||
#define AUDIO_FILE_ENCODING_ALAW_8 27
|
||||
|
||||
char *audio_enc_from_val (int);
|
||||
const char *audio_enc_from_val (int);
|
||||
int audio_enc_to_val (const char *);
|
||||
|
||||
int audio_sun_to_encoding (int, int *, int *);
|
||||
|
@ -121,7 +121,7 @@ int audio_encoding_to_sun (int, int, int *);
|
|||
#define IBM_FORMAT_ALAW (0x0102)
|
||||
#define IBM_FORMAT_ADPCM (0x0103)
|
||||
|
||||
char *wav_enc_from_val (int);
|
||||
const char *wav_enc_from_val (int);
|
||||
|
||||
typedef struct {
|
||||
char name[4];
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
|
||||
struct {
|
||||
int wenc;
|
||||
char *wname;
|
||||
const char *wname;
|
||||
} wavencs[] = {
|
||||
{ WAVE_FORMAT_UNKNOWN, "Microsoft Official Unknown" },
|
||||
{ WAVE_FORMAT_PCM, "Microsoft PCM" },
|
||||
|
@ -59,9 +59,8 @@ struct {
|
|||
{ -1, "?Unknown?" },
|
||||
};
|
||||
|
||||
char *
|
||||
wav_enc_from_val(encoding)
|
||||
int encoding;
|
||||
const char *
|
||||
wav_enc_from_val(int encoding)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -98,14 +97,19 @@ audio_wav_parse_hdr(hdr, sz, enc, prec, sample, channels, datasize)
|
|||
wav_audioheaderfmt fmt;
|
||||
char *end = (((char *)hdr) + sz);
|
||||
int newenc, newprec;
|
||||
|
||||
static const char
|
||||
strfmt[4] = "fmt ",
|
||||
strRIFF[4] = "RIFF",
|
||||
strWAVE[4] = "WAVE",
|
||||
strdata[4] = "data";
|
||||
|
||||
if (sz < 32)
|
||||
return (AUDIO_ENOENT);
|
||||
|
||||
if (strncmp(where, "RIFF", 4))
|
||||
if (strncmp(where, strRIFF, sizeof strRIFF))
|
||||
return (AUDIO_ENOENT);
|
||||
where += 8;
|
||||
if (strncmp(where, "WAVE", 4))
|
||||
if (strncmp(where, strWAVE, sizeof strWAVE))
|
||||
return (AUDIO_ENOENT);
|
||||
where += 4;
|
||||
|
||||
|
@ -113,7 +117,7 @@ audio_wav_parse_hdr(hdr, sz, enc, prec, sample, channels, datasize)
|
|||
memcpy(&part, where, sizeof part);
|
||||
owhere = where;
|
||||
where += getle32(part.len) + 8;
|
||||
} while (where < end && strncmp(part.name, "fmt ", 4));
|
||||
} while (where < end && strncmp(part.name, strfmt, sizeof strfmt));
|
||||
|
||||
/* too short ? */
|
||||
if (where + sizeof fmt > end)
|
||||
|
@ -176,7 +180,7 @@ printf("part `%c%c%c%c' len = %d\n", part.name[0], part.name[1], part.name[2], p
|
|||
#endif
|
||||
owhere = where;
|
||||
where += (getle32(part.len) + 8);
|
||||
} while ((char *)where < end && strncmp(part.name, "data", 4));
|
||||
} while (where < end && strncmp(part.name, strdata, sizeof strdata));
|
||||
|
||||
if ((where - getle32(part.len)) <= end) {
|
||||
if (channels)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: ctl.c,v 1.27 2001/03/28 03:18:39 simonb Exp $ */
|
||||
/* $NetBSD: ctl.c,v 1.28 2002/01/15 23:48:52 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1997 The NetBSD Foundation, Inc.
|
||||
|
@ -52,8 +52,8 @@
|
|||
|
||||
#include "libaudio.h"
|
||||
|
||||
struct field *findfield (char *name);
|
||||
void prfield (struct field *p, char *sep);
|
||||
struct field *findfield (const char *name);
|
||||
void prfield (struct field *p, const char *sep);
|
||||
void rdfield (struct field *p, char *q);
|
||||
void getinfo (int fd);
|
||||
void audioctl_write (int, int, char *[]);
|
||||
|
@ -71,7 +71,7 @@ char encbuf[1000];
|
|||
int properties, fullduplex, rerror;
|
||||
|
||||
struct field {
|
||||
char *name;
|
||||
const char *name;
|
||||
void *valp;
|
||||
int format;
|
||||
#define STRING 1
|
||||
|
@ -144,7 +144,7 @@ struct field {
|
|||
};
|
||||
|
||||
static struct {
|
||||
char *name;
|
||||
const char *name;
|
||||
u_int prop;
|
||||
} props[] = {
|
||||
{ "full_duplex", AUDIO_PROP_FULLDUPLEX },
|
||||
|
@ -155,7 +155,7 @@ static struct {
|
|||
|
||||
struct field *
|
||||
findfield(name)
|
||||
char *name;
|
||||
const char *name;
|
||||
{
|
||||
int i;
|
||||
for (i = 0; fields[i].name; i++)
|
||||
|
@ -167,10 +167,10 @@ findfield(name)
|
|||
void
|
||||
prfield(p, sep)
|
||||
struct field *p;
|
||||
char *sep;
|
||||
const char *sep;
|
||||
{
|
||||
u_int v;
|
||||
char *cm, *encstr;
|
||||
const char *cm, *encstr;
|
||||
int i;
|
||||
|
||||
if (sep)
|
||||
|
@ -345,7 +345,7 @@ main(argc, argv)
|
|||
int aflag = 0, wflag = 0;
|
||||
struct stat dstat, ostat;
|
||||
const char *file;
|
||||
char *sep = "=";
|
||||
const char *sep = "=";
|
||||
|
||||
file = getenv("AUDIOCTLDEVICE");
|
||||
if (file == 0)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: record.c,v 1.20 2002/01/15 17:17:13 mrg Exp $ */
|
||||
/* $NetBSD: record.c,v 1.21 2002/01/15 23:48:53 mrg Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1999 Matthew R. Green
|
||||
|
@ -52,8 +52,8 @@
|
|||
|
||||
audio_info_t info, oinfo;
|
||||
ssize_t total_size = -1;
|
||||
char *device;
|
||||
char *ctldev;
|
||||
const char *device;
|
||||
const char *ctldev;
|
||||
int format = AUDIO_FORMAT_SUN;
|
||||
char *header_info;
|
||||
char default_info[8] = { '\0', '\0', '\0', '\0', '\0', '\0', '\0', '\0' };
|
||||
|
@ -328,19 +328,22 @@ write_header_sun(hdrp, lenp, leftp)
|
|||
conv_func = swap_bytes;
|
||||
else if (precision == 32)
|
||||
conv_func = swap_bytes32;
|
||||
encoding = AUDIO_ENCODING_SLINEAR_BE;
|
||||
if (conv_func)
|
||||
encoding = AUDIO_ENCODING_SLINEAR_BE;
|
||||
} else if (encoding == AUDIO_ENCODING_ULINEAR_BE) {
|
||||
if (precision == 16)
|
||||
conv_func = change_sign16_be;
|
||||
else if (precision == 32)
|
||||
conv_func = change_sign32_be;
|
||||
encoding = AUDIO_ENCODING_SLINEAR_BE;
|
||||
if (conv_func)
|
||||
encoding = AUDIO_ENCODING_SLINEAR_BE;
|
||||
} else if (encoding == AUDIO_ENCODING_SLINEAR_LE) {
|
||||
if (precision == 16)
|
||||
conv_func = change_sign16_swap_bytes_le;
|
||||
else if (precision == 32)
|
||||
conv_func = change_sign32_swap_bytes_le;
|
||||
encoding = AUDIO_ENCODING_SLINEAR_BE;
|
||||
if (conv_func)
|
||||
encoding = AUDIO_ENCODING_SLINEAR_BE;
|
||||
}
|
||||
|
||||
/* if we can't express this as a Sun header, don't write any */
|
||||
|
@ -418,7 +421,10 @@ write_header_wav(hdrp, lenp, leftp)
|
|||
* RIFF\^@^C^@WAVEfmt ^P^@^@^@^A^@^B^@D<AC>^@^@^P<B1>^B^@^D^@^P^@data^@^@^C^@^@^@^@^@^@^@^@^@^@
|
||||
*/
|
||||
char wavheaderbuf[64], *p = wavheaderbuf;
|
||||
char *riff = "RIFF", *wavefmt = "WAVEfmt ", *fact = "fact", *data = "data";
|
||||
const char *riff = "RIFF",
|
||||
*wavefmt = "WAVEfmt ",
|
||||
*fact = "fact",
|
||||
*data = "data";
|
||||
u_int32_t filelen, fmtsz, sps, abps, factsz = 4, nsample, datalen;
|
||||
u_int16_t fmttag, nchan, align, bps, extln = 0;
|
||||
|
||||
|
|
Loading…
Reference in New Issue