Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/audio - WARNS=3 (from ross%netbsd.org@localhost)



details:   https://anonhg.NetBSD.org/src/rev/ff8c77a5a456
branches:  trunk
changeset: 520775:ff8c77a5a456
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Jan 15 23:48:51 2002 +0000

description:
- WARNS=3 (from ross%netbsd.org@localhost)
- fix a bug in WAV conversions

diffstat:

 usr.bin/audio/Makefile.inc      |   3 ++-
 usr.bin/audio/common/audio.c    |  16 ++++++++--------
 usr.bin/audio/common/libaudio.h |   6 +++---
 usr.bin/audio/common/wav.c      |  22 +++++++++++++---------
 usr.bin/audio/ctl/ctl.c         |  18 +++++++++---------
 usr.bin/audio/record/record.c   |  20 +++++++++++++-------
 6 files changed, 48 insertions(+), 37 deletions(-)

diffs (truncated from 302 to 300 lines):

diff -r c2e166cf4fa7 -r ff8c77a5a456 usr.bin/audio/Makefile.inc
--- a/usr.bin/audio/Makefile.inc        Tue Jan 15 21:01:59 2002 +0000
+++ b/usr.bin/audio/Makefile.inc        Tue Jan 15 23:48:51 2002 +0000
@@ -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
diff -r c2e166cf4fa7 -r ff8c77a5a456 usr.bin/audio/common/audio.c
--- a/usr.bin/audio/common/audio.c      Tue Jan 15 21:01:59 2002 +0000
+++ b/usr.bin/audio/common/audio.c      Tue Jan 15 23:48:51 2002 +0000
@@ -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 @@
 
 /* back and forth between encodings */
 struct {
-       char *ename;
+       const char *ename;
        int eno;
 } encs[] = {
        { AudioEmulaw,          AUDIO_ENCODING_ULAW },
@@ -105,7 +105,7 @@
 };
 
 
-char *
+const char *
 audio_enc_from_val(val)
        int     val;
 {
@@ -140,7 +140,7 @@
        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 @@
        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 @@
                        s = colon;
                }
        }
-       if ((dot = strchr(s, '.'))) {
+       if ((dot = strchr(s, '.')) != NULL) {
                int     i, base = 100000;
 
                *dot++ = '\0';
diff -r c2e166cf4fa7 -r ff8c77a5a456 usr.bin/audio/common/libaudio.h
--- a/usr.bin/audio/common/libaudio.h   Tue Jan 15 21:01:59 2002 +0000
+++ b/usr.bin/audio/common/libaudio.h   Tue Jan 15 23:48:51 2002 +0000
@@ -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 @@
 #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 @@
 #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];
diff -r c2e166cf4fa7 -r ff8c77a5a456 usr.bin/audio/common/wav.c
--- a/usr.bin/audio/common/wav.c        Tue Jan 15 21:01:59 2002 +0000
+++ b/usr.bin/audio/common/wav.c        Tue Jan 15 23:48:51 2002 +0000
@@ -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 @@
        { -1,                   "?Unknown?" },
 };
 
-char *
-wav_enc_from_val(encoding)
-       int encoding;
+const char *
+wav_enc_from_val(int encoding)
 {
        int     i;
 
@@ -98,14 +97,19 @@
        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 @@
                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 @@
 #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)
diff -r c2e166cf4fa7 -r ff8c77a5a456 usr.bin/audio/ctl/ctl.c
--- a/usr.bin/audio/ctl/ctl.c   Tue Jan 15 21:01:59 2002 +0000
+++ b/usr.bin/audio/ctl/ctl.c   Tue Jan 15 23:48:51 2002 +0000
@@ -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 @@
 int properties, fullduplex, rerror;
 
 struct field {
-       char *name;
+       const char *name;
        void *valp;
        int format;
 #define STRING 1
@@ -144,7 +144,7 @@
 };
 
 static struct {
-       char *name;
+       const char *name;
        u_int prop;
 } props[] = {
        { "full_duplex",        AUDIO_PROP_FULLDUPLEX },
@@ -155,7 +155,7 @@
 
 struct field *
 findfield(name)
-       char *name;
+       const char *name;
 {
        int i;
        for (i = 0; fields[i].name; i++)
@@ -167,10 +167,10 @@
 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 @@
        int aflag = 0, wflag = 0;
        struct stat dstat, ostat;
        const char *file;
-       char *sep = "=";
+       const char *sep = "=";
 
        file = getenv("AUDIOCTLDEVICE");
        if (file == 0)
diff -r c2e166cf4fa7 -r ff8c77a5a456 usr.bin/audio/record/record.c
--- a/usr.bin/audio/record/record.c     Tue Jan 15 21:01:59 2002 +0000
+++ b/usr.bin/audio/record/record.c     Tue Jan 15 23:48:51 2002 +0000
@@ -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 @@
                        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 @@
         *      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;



Home | Main Index | Thread Index | Old Index