ref: 3b89cf7fa3d1548b5b91133a11be2d4d88521bb1
parent: 852e497803ad66828a4ed4d34c9ebc1f919dfa4f
author: cbagwell <cbagwell>
date: Fri Jun 1 22:49:34 EDT 2001
Misc calculated buffer size when reaching EOF.
--- a/src/raw.c
+++ b/src/raw.c
@@ -277,6 +277,11 @@
/* Reads a buffer of different data types into SoX's internal buffer
* format.
*/
+/* FIXME: This function adds buffering on top of stdio's buffering.
+ * Mixing st_readbuf's and freads or fgetc or even SoX's other util
+ * functions will cause a loss of data! Need to have sox implement
+ * a consistent buffering protocol.
+ */
ULONG st_readbuf(LONG *p, int n, int size, int encoding, ft_t ft)
{
ULONG len, done = 0;
@@ -370,7 +375,7 @@
}
}
- len = MIN(n,(ft->file.count-ft->file.pos)/size);
+ len = MIN(n - done,(ft->file.count-ft->file.pos)/size);
if (len)
{
copy_buf(p + done, ft->file.buf + ft->file.pos, len, ft->swap);