shithub: sox

Download patch

ref: efad487ddcfd58db200cab4389a5856b97c0b26f
parent: 98cb9132420f6bfc2cc0ebd72f5de21b336ab0f4
author: cbagwell <cbagwell>
date: Sun Feb 28 15:23:33 EST 1999

Fixed minor problems related to new raw functions

--- a/src/aiff.c
+++ b/src/aiff.c
@@ -484,6 +484,7 @@
 		ft->info.size = WORD;
 	}
 	ft->info.style = SIGN2; /* We have a fixed style */
+
 	/* Compute the "very large number" so that a maximum number
 	   of samples can be transmitted through a pipe without the
 	   risk of causing overflow when calculating the number of bytes.
@@ -508,14 +509,16 @@
 {
 	struct aiffpriv *p = (struct aiffpriv *) ft->priv;
 
+	/* Needed because of rawwrite().  Call now to flush
+	 * buffer now before seeking around below.
+	 */
+	rawstopwrite(ft);
+
 	if (!ft->seekable)
 		return;
 	if (fseek(ft->fp, 0L, SEEK_SET) != 0)
 		fail("can't rewind output file to rewrite AIFF header");
 	aiffwriteheader(ft, p->nsamples / ft->info.channels);
-
-	/* Needed because of rawwrite() */
-	rawstopwrite(ft);
 }
 
 void aiffwriteheader(ft, nframes)
--- a/src/alsa.c
+++ b/src/alsa.c
@@ -55,6 +55,7 @@
     memset(&r_info, 0, sizeof(r_info));
     ioctl(fileno(ft->fp), SND_PCM_IOCTL_RECORD_INFO, &r_info);
     ft->file.count = 0;
+    ft->file.pos = 0;
     ft->file.eof = 0;
     ft->file.size = r_info.buffer_size;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
@@ -143,7 +144,7 @@
 
     memset(&p_info, 0, sizeof(p_info));
     ioctl(fileno(ft->fp), SND_PCM_IOCTL_PLAYBACK_INFO, &p_info);
-    ft->file.count = 0;
+    ft->file.pos = 0;
     ft->file.eof = 0;
     ft->file.size = p_info.buffer_size;
     if ((ft->file.buf = malloc (ft->file.size)) == NULL) {
--- a/src/au.c
+++ b/src/au.c
@@ -294,14 +294,16 @@
 {
 	struct aupriv *p = (struct aupriv *) ft->priv;
 
+	/* Needed because of rawwrite(). Do now to flush
+	 * data before seeking around below.
+	 */
+	rawstopwrite(ft);
+
 	if (!ft->seekable)
 		return;
 	if (fseek(ft->fp, 0L, 0) != 0)
 		fail("Can't rewind output file to rewrite Sun header.");
 	auwriteheader(ft, p->data_size);
-
-	/* Needed because of rawwrite() */
-	rawstopwrite(ft);
 }
 
 void auwriteheader(ft, data_size)
--- a/src/cdr.c
+++ b/src/cdr.c
@@ -143,6 +143,9 @@
 	int padsamps = SECTORSIZE - (cdr->samples % SECTORSIZE);
 	short zero;
 
+	/* Flush buffer before writing anything else */
+	rawstopwrite(ft);
+
 	zero = 0;
 
 	if (padsamps != SECTORSIZE) 
@@ -152,7 +155,5 @@
 			padsamps--;
 		}
 	}
-
-	rawstopwrite(ft);
 }