diff --git a/sndiod/abuf.c b/sndiod/abuf.c index d19a74a..7068312 100644 --- a/sndiod/abuf.c +++ b/sndiod/abuf.c @@ -72,7 +72,7 @@ abuf_done(struct abuf *buf) * Get a pointer to the readable block */ unsigned char * -abuf_rgetblk(struct abuf *buf, unsigned int *rsize) +abuf_rgetblk(struct abuf *buf, int *rsize) { unsigned int count; @@ -87,10 +87,10 @@ abuf_rgetblk(struct abuf *buf, unsigned int *rsize) * Discard the block at the start postion. */ void -abuf_rdiscard(struct abuf *buf, unsigned int count) +abuf_rdiscard(struct abuf *buf, int count) { #ifdef DEBUG - if (count > buf->used) { + if (count < 0 || count > buf->used) { log_puts("abuf_rdiscard: bad count = "); log_putu(count); log_puts("\n"); @@ -107,10 +107,10 @@ abuf_rdiscard(struct abuf *buf, unsigned int count) * Commit the data written at the end postion. */ void -abuf_wcommit(struct abuf *buf, unsigned int count) +abuf_wcommit(struct abuf *buf, int count) { #ifdef DEBUG - if (count > (buf->len - buf->used)) { + if (count < 0 || count > (buf->len - buf->used)) { log_puts("abuf_wcommit: bad count = "); log_putu(count); log_puts("\n"); @@ -124,9 +124,9 @@ abuf_wcommit(struct abuf *buf, unsigned int count) * Get a pointer to the writable block */ unsigned char * -abuf_wgetblk(struct abuf *buf, unsigned int *rsize) +abuf_wgetblk(struct abuf *buf, int *rsize) { - unsigned int end, avail, count; + int end, avail, count; end = buf->start + buf->used; if (end >= buf->len) diff --git a/sndiod/abuf.h b/sndiod/abuf.h index c7aec4c..b89acff 100644 --- a/sndiod/abuf.h +++ b/sndiod/abuf.h @@ -18,19 +18,19 @@ #define ABUF_H struct abuf { - unsigned int bpf; /* bytes per frames */ - unsigned int start; /* offset (frames) where stored data starts */ - unsigned int used; /* frames stored in the buffer */ - unsigned int len; /* total size of the buffer (frames) */ + int bpf; /* bytes per frames */ + int start; /* offset (frames) where stored data starts */ + int used; /* frames stored in the buffer */ + int len; /* total size of the buffer (frames) */ unsigned char *data; }; void abuf_init(struct abuf *, unsigned int, unsigned int); void abuf_done(struct abuf *); void abuf_log(struct abuf *); -unsigned char *abuf_rgetblk(struct abuf *, unsigned int *); -unsigned char *abuf_wgetblk(struct abuf *, unsigned int *); -void abuf_rdiscard(struct abuf *, unsigned int); -void abuf_wcommit(struct abuf *, unsigned int); +unsigned char *abuf_rgetblk(struct abuf *, int *); +unsigned char *abuf_wgetblk(struct abuf *, int *); +void abuf_rdiscard(struct abuf *, int); +void abuf_wcommit(struct abuf *, int); #endif /* !defined(ABUF_H) */ diff --git a/sndiod/file.c b/sndiod/file.c index 1a7c033..8210f7a 100644 --- a/sndiod/file.c +++ b/sndiod/file.c @@ -442,13 +442,11 @@ filelist_init(void) it.it_interval.tv_usec = TIMER_USEC; it.it_value.tv_sec = 0; it.it_value.tv_usec = TIMER_USEC; -#if 0 if (setitimer(ITIMER_REAL, &it, NULL) < 0) { perror("setitimer"); exit(1); } log_sync = 0; -#endif timo_init(); } diff --git a/sndiod/midi.c b/sndiod/midi.c index 02aba24..37879e4 100644 --- a/sndiod/midi.c +++ b/sndiod/midi.c @@ -235,7 +235,7 @@ int midi_in(struct midi *ep) { unsigned char c, *idata; - unsigned int i, icount; + int i, icount; if (ep->ibuf.used == 0) return 0; @@ -309,7 +309,7 @@ void midi_out(struct midi *oep, unsigned char *idata, int icount) { unsigned char *odata; - unsigned ocount; + int ocount; while (icount > 0) { if (oep->obuf.used == oep->obuf.len) { diff --git a/sndiod/miofile.c b/sndiod/miofile.c index 46ab34a..fe79005 100644 --- a/sndiod/miofile.c +++ b/sndiod/miofile.c @@ -102,7 +102,7 @@ miofile_in(void *arg) struct miofile *f = arg; struct midi *ep = f->port->midi; unsigned char *data; - unsigned int n, count; + int n, count; for (;;) { data = abuf_wgetblk(&ep->ibuf, &count); @@ -124,7 +124,7 @@ miofile_out(void *arg) struct miofile *f = arg; struct midi *ep = f->port->midi; unsigned char *data; - unsigned int n, count; + int n, count; for (;;) { data = abuf_rgetblk(&ep->obuf, &count); diff --git a/sndiod/sndiod.c b/sndiod/sndiod.c index cfaae25..5158203 100644 --- a/sndiod/sndiod.c +++ b/sndiod/sndiod.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include diff --git a/sndiod/sock.c b/sndiod/sock.c index 3f365e0..05a9551 100644 --- a/sndiod/sock.c +++ b/sndiod/sock.c @@ -507,9 +507,8 @@ int sock_rdata(struct sock *f) { struct abuf *buf; - unsigned int count; - char *data; - int n; + unsigned char *data; + int n, count; #ifdef DEBUG if (f->rtodo == 0) { @@ -581,10 +580,9 @@ int sock_wdata(struct sock *f) { static unsigned char dummy[AMSG_DATAMAX]; - int n; - char *data = NULL; - unsigned int count; + unsigned char *data = NULL; struct abuf *buf = NULL; + int n, count; #ifdef DEBUG if (f->wtodo == 0) {