ref: 24105030271f212b529e0c611606eae06e10eb40
parent: 28332df2dd56ba519b73627af6edd5f5b6855e48
author: rrt <rrt>
date: Sat Apr 7 18:57:27 EDT 2007
Change sox_readbuf and sox_writebuf to take a number of bytes rather than a number of elements and their size, as all calls (except those in my new I/O macros!) had either length or size set to 1 anyway.
--- a/src/8svx.c
+++ b/src/8svx.c
@@ -74,7 +74,7 @@
sox_seeki(ft,12,SEEK_CUR);
sox_readw(ft, &rate);
sox_seeki(ft,1,SEEK_CUR);
- sox_readbuf(ft, buf,1,1);
+ sox_readbuf(ft, buf,1);
if (buf[0] != 0)
{
sox_fail_errno(ft, SOX_EFMT, "Unsupported data compression");
@@ -89,7 +89,7 @@
if (chunksize & 1)
chunksize++;
chunk_buf = (char *) xmalloc(chunksize + 2);
- if (sox_readbuf(ft, chunk_buf,1,(size_t)chunksize)
+ if (sox_readbuf(ft, chunk_buf,(size_t)chunksize)
!= chunksize)
{
sox_fail_errno(ft, SOX_EHDR, "Couldn't read all of header");
@@ -107,7 +107,7 @@
if (chunksize & 1)
chunksize++;
chunk_buf = (char *) xmalloc(chunksize + 1);
- if (sox_readbuf(ft, chunk_buf,1,(size_t)chunksize)
+ if (sox_readbuf(ft, chunk_buf,(size_t)chunksize)
!= chunksize)
{
sox_fail_errno(ft, SOX_EHDR, "Couldn't read all of header");
--- a/src/adpcms.c
+++ b/src/adpcms.c
@@ -221,7 +221,7 @@
state->file.buf[state->file.count++] = byte;
if (state->file.count >= state->file.size) {
- sox_writebuf(ft, state->file.buf, 1, state->file.count);
+ sox_writebuf(ft, state->file.buf, state->file.count);
state->file.count = 0;
}
@@ -263,7 +263,7 @@
}
if (state->file.count > 0)
- sox_writebuf(ft, state->file.buf, 1, state->file.count);
+ sox_writebuf(ft, state->file.buf, state->file.count);
}
/******************************************************************************
--- a/src/aiff.c
+++ b/src/aiff.c
@@ -521,7 +521,7 @@
sox_readdw(ft, &chunksize);
/* allocate enough memory to hold the text including a terminating \0 */
*text = (char *) xmalloc((size_t) chunksize + 1);
- if (sox_readbuf(ft, *text, 1, chunksize) != chunksize)
+ if (sox_readbuf(ft, *text, chunksize) != chunksize)
{
sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
return(SOX_EOF);
@@ -531,7 +531,7 @@
{
/* Read past pad byte */
char c;
- if (sox_readbuf(ft, &c, 1, 1) != 1)
+ if (sox_readbuf(ft, &c, 1) != 1)
{
sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
return(SOX_EOF);
@@ -576,7 +576,7 @@
*text = xrealloc(*text, (size_t) totalCommentLength + 1);
}
- if (sox_readbuf(ft, *text + totalCommentLength - commentLength, 1, commentLength) != commentLength) {
+ if (sox_readbuf(ft, *text + totalCommentLength - commentLength, commentLength) != commentLength) {
sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
return(SOX_EOF);
}
@@ -585,7 +585,7 @@
if (commentLength % 2) {
/* Read past pad byte */
char c;
- if (sox_readbuf(ft, &c, 1, 1) != 1) {
+ if (sox_readbuf(ft, &c, 1) != 1) {
sox_fail_errno(ft,SOX_EOF,"AIFF: Unexpected EOF in %s header", chunkDescription);
return(SOX_EOF);
}
@@ -596,9 +596,8 @@
if (totalReadLength < chunksize) {
size_t i;
char c;
- for (i=0; i < chunksize - totalReadLength; i++ ) {
- sox_readbuf(ft, &c, 1, 1);
- }
+ for (i=0; i < chunksize - totalReadLength; i++ )
+ sox_readbuf(ft, &c, 1);
}
return(SOX_SUCCESS);
}
@@ -627,7 +626,7 @@
{
while (! sox_eof(ft))
{
- if (sox_readbuf(ft, buf, 1, 4) != 4)
+ if (sox_readbuf(ft, buf, 4) != 4)
break;
sox_readdw(ft, &chunksize);
@@ -998,7 +997,7 @@
static double read_ieee_extended(ft_t ft)
{
char buf[10];
- if (sox_readbuf(ft, buf, 1, 10) != 10)
+ if (sox_readbuf(ft, buf, 10) != 10)
{
sox_fail_errno(ft,SOX_EOF,"EOF while reading IEEE extended number");
return(SOX_EOF);
@@ -1010,13 +1009,11 @@
{
char buf[10];
ConvertToIeeeExtended(x, buf);
- /*
- sox_debug("converted %g to %o %o %o %o %o %o %o %o %o %o",
+ sox_debug_more("converted %g to %o %o %o %o %o %o %o %o %o %o",
x,
buf[0], buf[1], buf[2], buf[3], buf[4],
buf[5], buf[6], buf[7], buf[8], buf[9]);
- */
- (void)sox_writebuf(ft, buf, 1, 10);
+ (void)sox_writebuf(ft, buf, 10);
}
--- a/src/auto.c
+++ b/src/auto.c
@@ -38,7 +38,7 @@
* file. So we start checking for those filetypes first.
*/
memset(header,0,4);
- if (sox_readbuf(ft, header, 1, 4) == 4)
+ if (sox_readbuf(ft, header, 4) == 4)
{
/* Look for .snd or dns. header of AU files */
if ((strncmp(header, ".snd", 4) == 0) ||
@@ -51,7 +51,7 @@
else if (strncmp(header, "FORM", 4) == 0)
{
/* Need to read more data to see what type of FORM file */
- if (sox_readbuf(ft, header, 1, 8) == 8)
+ if (sox_readbuf(ft, header, 8) == 8)
{
if (strncmp(header + 4, "AIFF", 4) == 0)
type = "aiff";
@@ -65,13 +65,13 @@
}
else if (strncmp(header, "RIFF", 4) == 0)
{
- if (sox_readbuf(ft, header, 1, 8) == 8)
+ if (sox_readbuf(ft, header, 8) == 8)
if (strncmp(header + 4, "WAVE", 4) == 0)
type = "wav";
}
else if (strncmp(header, "Crea", 4) == 0)
{
- if (sox_readbuf(ft, header, 1, 15) == 15)
+ if (sox_readbuf(ft, header, 15) == 15)
if (strncmp(header, "tive Voice File", 15) == 0)
type = "voc";
}
@@ -78,10 +78,10 @@
else if (strncmp(header, "SOUN", 4) == 0)
{
/* Check for SOUND magic header */
- if (sox_readbuf(ft, header, 1, 1) == 1 && *header == 'D')
+ if (sox_readbuf(ft, header, 1) == 1 && *header == 'D')
{
/* Once we've found SOUND see if its smp or sndt */
- if (sox_readbuf(ft, header, 1, 12) == 12)
+ if (sox_readbuf(ft, header, 12) == 12)
{
if (strncmp(header, " SAMPLE DATA", 12) == 0)
type = "smp";
@@ -96,13 +96,13 @@
type = "avr";
else if (strncmp(header, "NIST", 4) == 0)
{
- if (sox_readbuf(ft, header, 1, 3) == 3)
+ if (sox_readbuf(ft, header, 3) == 3)
if (strncmp(header, "_1A", 3) == 0)
type = "sph";
}
else if (strncmp(header, "ALaw", 4) == 0)
{
- if (sox_readbuf(ft, header, 1, 11) == 11)
+ if (sox_readbuf(ft, header, 11) == 11)
if (strncmp(header, "SoundFile**", 11) == 0)
type = "wve";
}
@@ -122,15 +122,15 @@
if (type == NULL)
{
for (loop = 0; loop < 60; loop++)
- if (sox_readbuf(ft, header, 1, 1) != 1)
+ if (sox_readbuf(ft, header, 1) != 1)
break;
- if (sox_readbuf(ft, header, 1, 4) == 4 &&
+ if (sox_readbuf(ft, header, 4) == 4 &&
strncmp(header, "FSSD", 4) == 0)
{
for (loop = 0; loop < 62; loop++)
- if (sox_readbuf(ft, header, 1, 1) != 1)
+ if (sox_readbuf(ft, header, 1) != 1)
break;
- if (sox_readbuf(ft, header, 1, 4) == 0 &&
+ if (sox_readbuf(ft, header, 4) == 0 &&
strncmp(header, "HCOM", 4) == 0)
type = "hcom";
}
--- a/src/avr.c
+++ b/src/avr.c
@@ -75,7 +75,7 @@
return(SOX_EOF);
}
- sox_readbuf(ft, avr->name, 1, sizeof(avr->name));
+ sox_readbuf(ft, avr->name, sizeof(avr->name));
sox_readw (ft, &(avr->mono));
if (avr->mono) {
@@ -130,9 +130,9 @@
sox_readw (ft, &(avr->res3));
- sox_readbuf(ft, avr->ext, 1, sizeof(avr->ext));
+ sox_readbuf(ft, avr->ext, sizeof(avr->ext));
- sox_readbuf(ft, avr->user, 1, sizeof(avr->user));
+ sox_readbuf(ft, avr->user, sizeof(avr->user));
rc = sox_rawstartread (ft);
if (rc)
@@ -234,7 +234,7 @@
sox_writew (ft, 0);
/* ext */
- sox_writebuf(ft, (void *)"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", 1, sizeof(avr->ext));
+ sox_writebuf(ft, (void *)"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", sizeof(avr->ext));
/* user */
sox_writebuf(ft,
@@ -241,7 +241,7 @@
(void *)"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
"\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"
- "\0\0\0\0", 1, sizeof (avr->user));
+ "\0\0\0\0", sizeof (avr->user));
return(SOX_SUCCESS);
}
--- a/src/cvsd.c
+++ b/src/cvsd.c
@@ -371,7 +371,7 @@
int i;
unsigned sum;
- if (sox_readbuf(ft, hdrbuf, sizeof(hdrbuf), 1) != 1)
+ if (sox_readbuf(ft, hdrbuf, sizeof(hdrbuf)) != sizeof(hdrbuf))
{
return (SOX_EOF);
}
@@ -442,7 +442,7 @@
sox_report("seek failed\n: %s",strerror(errno));
return (SOX_EOF);
}
- if (sox_writebuf(ft, hdrbuf, sizeof(hdrbuf), 1) != 1)
+ if (sox_writebuf(ft, hdrbuf, sizeof(hdrbuf)) != sizeof(hdrbuf))
{
sox_report("%s",strerror(errno));
return (SOX_EOF);
--- a/src/flac.c
+++ b/src/flac.c
@@ -258,7 +258,7 @@
ft_t const format = (ft_t) client_data;
(void) flac, (void) samples, (void) current_frame;
- return sox_writebuf(format, buffer, 1, bytes) == bytes ? FLAC__STREAM_ENCODER_WRITE_STATUS_OK : FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
+ return sox_writebuf(format, buffer, bytes) == bytes ? FLAC__STREAM_ENCODER_WRITE_STATUS_OK : FLAC__STREAM_ENCODER_WRITE_STATUS_FATAL_ERROR;
}
--- a/src/gsm.c
+++ b/src/gsm.c
@@ -122,8 +122,9 @@
if (done>=samp) break;
- r = sox_readbuf(ft, p->frames, p->channels*FRAMESIZE, 1);
- if (r != 1) break;
+ r = sox_readbuf(ft, p->frames, p->channels * FRAMESIZE);
+ if (r != p->channels * FRAMESIZE)
+ break;
p->samplePtr = p->samples;
for (ch=0; ch<chans; ch++) {
@@ -171,8 +172,8 @@
gsp += chans;
}
gsm_encode(p->handle[ch], gbuff, p->frames);
- r = sox_writebuf(ft, p->frames, FRAMESIZE, 1);
- if (r != 1)
+ r = sox_writebuf(ft, p->frames, FRAMESIZE);
+ if (r != FRAMESIZE)
{
sox_fail_errno(ft,errno,"write error");
return(SOX_EOF);
--- a/src/hcom.c
+++ b/src/hcom.c
@@ -438,7 +438,7 @@
free((char *)p->data);
/* Write the header */
- sox_writebuf(ft, (void *)"\000\001A", 1, 3); /* Dummy file name "A" */
+ sox_writebuf(ft, (void *)"\000\001A", 3); /* Dummy file name "A" */
sox_padbytes(ft, 65-3);
sox_writes(ft, "FSSD");
sox_padbytes(ft, 83-69);
@@ -448,7 +448,7 @@
if (sox_error(ft)) {
sox_fail_errno(ft, errno, "write error in HCOM header");
rc = SOX_EOF;
- } else if (sox_writebuf(ft, compressed_data, 1, compressed_len) != compressed_len) {
+ } else if (sox_writebuf(ft, compressed_data, compressed_len) != compressed_len) {
/* Write the compressed_data fork */
sox_fail_errno(ft, errno, "can't write compressed HCOM data");
rc = SOX_EOF;
--- a/src/maud.c
+++ b/src/maud.c
@@ -167,7 +167,7 @@
if (chunksize & 1)
chunksize++;
chunk_buf = (char *) xmalloc(chunksize + 1);
- if (sox_readbuf(ft, chunk_buf, 1, chunksize)
+ if (sox_readbuf(ft, chunk_buf, chunksize)
!= chunksize)
{
sox_fail_errno(ft,SOX_EOF,"MAUD: Unexpected EOF in ANNO header");
--- a/src/misc.c
+++ b/src/misc.c
@@ -109,12 +109,12 @@
/* Utilities */
-/* Read in a buffer of data of length len and each element is size bytes.
- * Returns number of elements read, not bytes read.
+/* Read in a buffer of data of length len bytes.
+ * Returns number of bytes read.
*/
-size_t sox_readbuf(ft_t ft, void *buf, size_t size, sox_size_t len)
+size_t sox_readbuf(ft_t ft, void *buf, sox_size_t len)
{
- return fread(buf, size, len, ft->fp);
+ return fread(buf, 1, len, ft->fp);
}
/* Skip input without seeking. */
@@ -139,13 +139,13 @@
return (SOX_SUCCESS);
}
-/* Write a buffer of data of length len and each element is size bytes.
- * Returns number of elements writen, not bytes written.
+/* Write a buffer of data of length bytes.
+ * Returns number of bytes written.
*/
-size_t sox_writebuf(ft_t ft, void const *buf, size_t size, sox_size_t len)
+size_t sox_writebuf(ft_t ft, void const *buf, sox_size_t len)
{
- return fwrite(buf, size, len, ft->fp);
+ return fwrite(buf, 1, len, ft->fp);
}
sox_size_t sox_filelength(ft_t ft)
@@ -201,7 +201,7 @@
sc = c;
do
{
- if (sox_readbuf(ft, &in, 1, 1) != 1)
+ if (sox_readbuf(ft, &in, 1) != 1)
{
*sc = 0;
sox_fail_errno(ft,errno,sox_readerr);
@@ -220,7 +220,7 @@
/* Write null-terminated string (without \0). */
int sox_writes(ft_t ft, char const * c)
{
- if (sox_writebuf(ft, c, 1, strlen(c)) != strlen(c))
+ if (sox_writebuf(ft, c, strlen(c)) != strlen(c))
{
sox_fail_errno(ft,errno,sox_writerr);
return(SOX_EOF);
--- a/src/mp3.c
+++ b/src/mp3.c
@@ -107,7 +107,7 @@
*/
memmove(p->InputBuffer, p->Stream->next_frame, remaining);
- bytes_read = sox_readbuf(ft, p->InputBuffer+remaining, 1,
+ bytes_read = sox_readbuf(ft, p->InputBuffer+remaining,
INPUT_BUFFER_SIZE-remaining);
if (bytes_read == 0)
{
@@ -188,7 +188,7 @@
* format. The decoded frame will be saved off so that it
* can be processed later.
*/
- ReadSize=sox_readbuf(ft, p->InputBuffer, 1, INPUT_BUFFER_SIZE);
+ ReadSize=sox_readbuf(ft, p->InputBuffer, INPUT_BUFFER_SIZE);
if(ReadSize<=0)
{
if(sox_error(ft))
@@ -488,7 +488,7 @@
goto end;
}
- if (sox_writebuf(ft, mp3buffer, 1, written) < written)
+ if (sox_writebuf(ft, mp3buffer, written) < written)
{
sox_fail_errno(ft,SOX_EOF,"File write failed");
goto end;
@@ -517,7 +517,7 @@
if ( (written=lame_encode_flush(p->gfp, (unsigned char *)mp3buffer, 7200)) <0){
sox_fail_errno(ft,SOX_EOF,"Encoding failed");
}
- else if (sox_writebuf(ft, mp3buffer, 1, written2 = written) < written2){
+ else if (sox_writebuf(ft, mp3buffer, written2 = written) < written2){
sox_fail_errno(ft,SOX_EOF,"File write failed");
}
--- a/src/prc.c
+++ b/src/prc.c
@@ -107,7 +107,7 @@
int prc_checkheader(ft_t ft, char *head)
{
- sox_readbuf(ft, head, 1, sizeof(prc_header));
+ sox_readbuf(ft, head, sizeof(prc_header));
return memcmp(head, prc_header, sizeof(prc_header)) == 0;
}
@@ -438,7 +438,7 @@
{
prc_t p = (prc_t)ft->priv;
- sox_writebuf(ft, prc_header, 1, sizeof(prc_header));
+ sox_writebuf(ft, prc_header, sizeof(prc_header));
sox_writes(ft, "\x2arecord.app");
sox_debug("Number of samples: %d",p->nsamp);
--- a/src/raw.c
+++ b/src/raw.c
@@ -121,8 +121,9 @@
{ \
sox_size_t n = 0, nread; \
ctype *data = xmalloc(sizeof(ctype) * len); \
- if ((nread = sox_readbuf(ft, (uctype *)data, size, len)) != len) \
+ if ((nread = sox_readbuf(ft, data, len * size)) != len * size) \
sox_fail_errno(ft, errno, sox_readerr); \
+ nread /= size; \
for (; n < nread; n++) { \
twiddle(((uctype *)data)[n], type); \
*buf++ = cast(data[n], ft->clips); \
@@ -139,7 +140,7 @@
sox_size_t n; \
for (n = 0; n < len; n++) { \
ctype datum = 0; \
- if (sox_readbuf(ft, (uctype *)&datum, size, 1) != 1) { \
+ if (sox_readbuf(ft, &datum, size) != size) { \
sox_fail_errno(ft, errno, sox_readerr); \
break; \
} \
@@ -187,10 +188,10 @@
data[n] = cast(*buf++, ft->clips); \
twiddle(((uctype *)data)[n], type); \
} \
- if ((nwritten = sox_writebuf(ft, (uctype *)data, size, len)) != len) \
+ if ((nwritten = sox_writebuf(ft, data, len * size)) != len * size) \
sox_fail_errno(ft, errno, sox_readerr); \
free(data); \
- return nwritten; \
+ return nwritten / size; \
}
/* This (slower) macro works for 3-byte types. */
@@ -202,7 +203,7 @@
for (n = 0; n < len; n++) { \
ctype datum = cast(*buf++, ft->clips); \
twiddle(datum, type); \
- if (sox_writebuf(ft, (uctype *)&datum, size, 1) != 1) { \
+ if (sox_writebuf(ft, &datum, size) != size) { \
sox_fail_errno(ft, errno, sox_readerr); \
break; \
} \
--- a/src/sf.c
+++ b/src/sf.c
@@ -98,7 +98,7 @@
int rc;
int samplesize = 0;
- if (sox_readbuf(ft, &sfhead, 1, sizeof(sfhead)) != sizeof(sfhead))
+ if (sox_readbuf(ft, &sfhead, sizeof(sfhead)) != sizeof(sfhead))
{
sox_fail("unexpected EOF in SF header");
return(SOX_EOF);
@@ -212,7 +212,7 @@
sfcharp = (char *) sfcodep + sizeof(SFCODE);
while(sfcharp < (char *) &sfhead + SIZEOF_HEADER)
*sfcharp++ = '\0';
- sox_writebuf(ft, &sfhead, 1, sizeof(SFHEADER));
+ sox_writebuf(ft, &sfhead, sizeof(SFHEADER));
return(SOX_SUCCESS);
}
--- a/src/smp.c
+++ b/src/smp.c
@@ -91,7 +91,7 @@
ft->loops[i].count = trailer->loops[i].count;
}
for(i = 0; i < 8; i++) { /* read the 8 markers */
- if (sox_readbuf(ft, trailer->markers[i].name, 1, MARKERLEN) != 10)
+ if (sox_readbuf(ft, trailer->markers[i].name, MARKERLEN) != MARKERLEN)
{
sox_fail_errno(ft,SOX_EHDR,"EOF in SMP");
return(SOX_EOF);
@@ -217,7 +217,7 @@
}
/* Read SampleVision header */
- if (sox_readbuf(ft, (char *)&header, 1, HEADERSIZE) != HEADERSIZE)
+ if (sox_readbuf(ft, (char *)&header, HEADERSIZE) != HEADERSIZE)
{
sox_fail_errno(ft,SOX_EHDR,"unexpected EOF in SMP header");
return(SOX_EOF);
@@ -356,7 +356,7 @@
sprintf(header.name, "%-*.*s", NAMELEN, NAMELEN, ft->comment);
/* Write file header */
- if(sox_writebuf(ft, &header, 1, HEADERSIZE) != HEADERSIZE)
+ if(sox_writebuf(ft, &header, HEADERSIZE) != HEADERSIZE)
{
sox_fail_errno(ft,errno,"SMP: Can't write header completely");
return(SOX_EOF);
--- a/src/sndrtool.c
+++ b/src/sndrtool.c
@@ -37,7 +37,7 @@
sox_writew (ft,4);
memset (name_buf, 0, 96);
sprintf (name_buf,"%.62s - File created by SoX",ft->filename);
- sox_writebuf(ft, name_buf, 1, 96);
+ sox_writebuf(ft, name_buf, 96);
}
static int sox_sndseek(ft_t ft, sox_size_t offset)
@@ -82,7 +82,7 @@
and second word is between 4000 & 25000 then this is sounder sound */
/* otherwise, its probably raw, not handled here */
- if (sox_readbuf(ft, buf, 1, 2) != 2)
+ if (sox_readbuf(ft, buf, 2) != 2)
{
sox_fail_errno(ft,errno,"SND: unexpected EOF");
return(SOX_EOF);
@@ -101,7 +101,7 @@
else
{
/* sndtool ? */
- sox_readbuf(ft, &buf[2], 1, 6);
+ sox_readbuf(ft, &buf[2], 6);
if (strncmp(buf,"SOUND",5))
{
sox_fail_errno(ft,SOX_EFMT,"SND: unrecognized SND format");
--- a/src/sox_i.h
+++ b/src/sox_i.h
@@ -99,10 +99,10 @@
* possible byte swapping.
*/
/* declared in misc.c */
-size_t sox_readbuf(ft_t ft, void *buf, size_t size, sox_size_t len);
+size_t sox_readbuf(ft_t ft, void *buf, sox_size_t len);
int sox_skipbytes(ft_t ft, sox_size_t n);
int sox_padbytes(ft_t ft, sox_size_t n);
-size_t sox_writebuf(ft_t ft, void const *buf, size_t size, sox_size_t len);
+size_t sox_writebuf(ft_t ft, void const *buf, sox_size_t len);
int sox_reads(ft_t ft, char *c, sox_size_t len);
int sox_writes(ft_t ft, char const * c);
--- a/src/sphere.c
+++ b/src/sphere.c
@@ -137,7 +137,7 @@
while (header_size)
{
- bytes_read = sox_readbuf(ft, buf, SOX_SIZE_BYTE, header_size);
+ bytes_read = sox_readbuf(ft, buf, header_size);
if (bytes_read == 0)
{
free(buf);
--- a/src/tx16w.c
+++ b/src/tx16w.c
@@ -262,7 +262,7 @@
/* dummy numbers, just for place holder, real header is written
at end of processing, since byte count is needed */
- sox_writebuf(ft, &WH, 1, 32);
+ sox_writebuf(ft, &WH, 32);
writedone = 32;
return(SOX_SUCCESS);
}
@@ -362,7 +362,7 @@
magic2[WH.sample_rate];
sox_rewind(ft);
- sox_writebuf(ft, &WH, 1, 32);
+ sox_writebuf(ft, &WH, 32);
return(SOX_SUCCESS);
}
--- a/src/voc.c
+++ b/src/voc.c
@@ -219,7 +219,7 @@
int ii; /* for getting rid of lseek */
unsigned char uc;
- if (sox_readbuf(ft, header, 1, 20) != 20)
+ if (sox_readbuf(ft, header, 20) != 20)
{
sox_fail_errno(ft,SOX_EHDR,"unexpected EOF in VOC header");
return(SOX_EOF);
--- a/src/vorbis.c
+++ b/src/vorbis.c
@@ -260,8 +260,8 @@
static int oe_write_page(ogg_page *page, ft_t ft)
{
int written;
- written = sox_writebuf(ft, page->header,1,(sox_size_t)page->header_len);
- written += sox_writebuf(ft, page->body,1,(sox_size_t)page->body_len);
+ written = sox_writebuf(ft, page->header,(sox_size_t)page->header_len);
+ written += sox_writebuf(ft, page->body,(sox_size_t)page->body_len);
return written;
}
--- a/src/wav.c
+++ b/src/wav.c
@@ -81,7 +81,7 @@
int samplesThisBlock;
/* Pull in the packet and check the header */
- bytesRead = sox_readbuf(ft, wav->packet, 1, wav->blockAlign);
+ bytesRead = sox_readbuf(ft, wav->packet, wav->blockAlign);
samplesThisBlock = wav->samplesPerBlock;
if (bytesRead < wav->blockAlign)
{
@@ -122,7 +122,7 @@
const char *errmsg;
/* Pull in the packet and check the header */
- bytesRead = sox_readbuf(ft, wav->packet, 1, wav->blockAlign);
+ bytesRead = sox_readbuf(ft, wav->packet, wav->blockAlign);
samplesThisBlock = wav->samplesPerBlock;
if (bytesRead < wav->blockAlign)
{
@@ -168,7 +168,7 @@
ImaBlockMashI(chans, wav->samples, wav->samplesPerBlock, wav->state, wav->packet, 9);
}
/* write the compressed packet */
- if (sox_writebuf(ft, wav->packet, wav->blockAlign, 1) != 1)
+ if (sox_writebuf(ft, wav->packet, wav->blockAlign) != wav->blockAlign)
{
sox_fail_errno(ft,SOX_EOF,"write error");
return (SOX_EOF);
@@ -234,7 +234,7 @@
/* read and decode loop, possibly leaving some samples in wav->gsmsample */
while (done < len) {
wav->gsmindex=0;
- bytes = sox_readbuf(ft, frame, 1, 65);
+ bytes = sox_readbuf(ft, frame, 65);
if (bytes <=0)
return done;
if (bytes<65) {
@@ -275,7 +275,7 @@
gsm_encode(wav->gsmhandle, wav->gsmsample, frame);
/*encode the odd half long (33 byte) frame */
gsm_encode(wav->gsmhandle, wav->gsmsample+160, frame+32);
- if (sox_writebuf(ft, frame, 1, 65) != 65)
+ if (sox_writebuf(ft, frame, 65) != 65)
{
sox_fail_errno(ft,SOX_EOF,"write error");
return (SOX_EOF);
--- a/src/xa.c
+++ b/src/xa.c
@@ -95,7 +95,7 @@
char *magic = xa->header.magic;
/* Check for the magic value */
- if (sox_readbuf(ft, xa->header.magic, 1, 4) != 4 ||
+ if (sox_readbuf(ft, xa->header.magic, 4) != 4 ||
(memcmp("XA\0\0", xa->header.magic, 4) != 0 &&
memcmp("XAI\0", xa->header.magic, 4) != 0 &&
memcmp("XAJ\0", xa->header.magic, 4) != 0))
@@ -206,7 +206,7 @@
while (done < len) {
if (xa->bufPos >= xa->blockSize) {
/* Read the next block */
- bytes = sox_readbuf(ft, xa->buf, 1, xa->blockSize);
+ bytes = sox_readbuf(ft, xa->buf, xa->blockSize);
if (bytes < xa->blockSize) {
if (sox_eof(ft)) {
if (done > 0) {