ref: b5db60e89ae731cf22f7405722353b06d9b8977f
parent: f6508ee2270bade4ff957e22084a017f36a07dfa
author: cbagwell <cbagwell>
date: Sat Sep 22 16:29:21 EDT 2001
Moving checks for channel and rate channel effect errors from sox.c to each effect. This lets the pan effect work again. Added a buffer flush in sunaudio to remove any trash audio.
--- a/Changelog
+++ b/Changelog
@@ -4,6 +4,15 @@
This file contains a list of all changes starting after the release of
sox-11gamma.
+sox-12.17.3
+-----------
+ o Removed check that prevented pan from being invoked when the
+ input and output channels were the same.
+ o Ciaran Anscomb added a flush to sunaudio driver after changing
+ settings. This is because it can start buffering data as soon
+ as the device is open and the buffered data can be in a
+ wrong format.
+
sox-12.17.2
-----------
o Daniel Culbert found and fixed a bug in the polyphase effect
--- a/src/polyphas.c
+++ b/src/polyphas.c
@@ -390,6 +390,12 @@
int total, size, uprate;
int k;
+ if (effp->ininfo.rate == effp->outinfo.rate)
+ {
+ st_fail("Input and Output rate must not be the same to use polyphase effect");
+ return(ST_EOF);
+ }
+
st_initrand();
rate->lcmrate = st_lcm((LONG)effp->ininfo.rate, (LONG)effp->outinfo.rate);
--- a/src/rate.c
+++ b/src/rate.c
@@ -75,6 +75,12 @@
rate_t rate = (rate_t) effp->priv;
ULONG incr;
+ if (effp->ininfo.rate == effp->outinfo.rate)
+ {
+ st_fail("Input and Output rates must be different to use rate effect");
+ return(ST_EOF);
+ }
+
if (effp->ininfo.rate >= 65535 || effp->outinfo.rate >= 65535)
{
st_fail("rate effect can only handle rates <= 65535");
--- a/src/resample.c
+++ b/src/resample.c
@@ -183,6 +183,12 @@
int i;
extern LONG st_gcd(LONG a,LONG b);
+ if (effp->ininfo.rate == effp->outinfo.rate)
+ {
+ st_fail("Input and Output rates must be different to use resample effect");
+ return(ST_EOF);
+ }
+
r->Factor = (double)effp->outinfo.rate / (double)effp->ininfo.rate;
gcdrate = st_gcd((LONG)effp->ininfo.rate, (LONG)effp->outinfo.rate);
--- a/src/sox.c
+++ b/src/sox.c
@@ -989,11 +989,7 @@
if (haschan > 1)
st_fail("Can not specify multiple effects that modify channel #");
if (hasrate > 1)
- st_fail("Can not specify multiple effects that change sample rate");
- if (haschan && !needchan)
- st_fail("Can not specify channel effects when input and output channel # are equal");
- if (hasrate && !needrate)
- st_fail("Can not specify sample rate effects when input and output rate are equal");
+ st_report("Can not specify multiple effects that change sample rate");
/* If not writing output then do not worry about adding
* channel and rate effects. This is just to speed things
--- a/src/sunaudio.c
+++ b/src/sunaudio.c
@@ -166,6 +166,8 @@
st_fail_errno(ft,errno,"Unable to initialize encoding for /dev/audio");
return(ST_EOF);
}
+ /* Flush any data in the buffers - its probably in the wrong format */
+ ioctl(fileno(ft->fp), I_FLUSH, FLUSHR);
/* Change to non-buffered I/O*/
setvbuf(ft->fp, NULL, _IONBF, sizeof(char) * ft->file.size);
sigintreg(ft); /* Prepare to catch SIGINT */
--- a/src/tests.sh
+++ b/src/tests.sh
@@ -28,9 +28,9 @@
rm -f ub.raw ub.au ub2.raw ub.sf
./sox $noise ub2.sf ub2.aiff
./sox $noise ub2.aiff ub3.sf
-echo Comparing ub2.sf to ub3.sf, ignoring Comment field
-cmp -l ub2.sf ub3.sf | grep -v '^ 2[3456789]'
-#rm -f ub2.sf ub2.aiff ub3.sf
+echo Comparing ub2.sf to ub3.sf
+cmp -l ub2.sf ub3.sf
+rm -f ub2.sf ub2.aiff ub3.sf
#
# Cmp -l of stop.raw and stop2.raw will show that most of the
# bytes are 1 apart. This is quantization error.