ref: 761a3593cbde34f81b18cd1a7bb7b3b38ce02bb9
parent: 4eddd5b3f9425988478f6b5856364c5f61615795
author: cbagwell <cbagwell>
date: Sun Mar 19 18:44:24 EST 2006
Updates to effects to return EOF when finished.
--- a/Changelog
+++ b/Changelog
@@ -36,6 +36,8 @@
o Prevent crashes when printing error mesages (1447239)
o Added makefile and support files to compile using Open Watcom
compiler. (1417798) Marty
+ o Stop calling flow() on effects that returned EOF during drain(). Allows
+ two back-to-back reverse effects to work.
sox-12.17.9
-----------
--- a/src/chorus.c
+++ b/src/chorus.c
@@ -326,7 +326,10 @@
}
/* samples played, it remains */
*osamp = done;
- return (ST_SUCCESS);
+ if (chorus->fade_out == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
/*
--- a/src/echo.c
+++ b/src/echo.c
@@ -251,7 +251,10 @@
};
/* samples played, it remains */
*osamp = done;
- return (ST_SUCCESS);
+ if (echo->fade_out == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
/*
--- a/src/echos.c
+++ b/src/echos.c
@@ -255,7 +255,10 @@
};
/* samples played, it remains */
*osamp = done;
- return (ST_SUCCESS);
+ if (echos->sumsamples == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
/*
--- a/src/phaser.c
+++ b/src/phaser.c
@@ -257,7 +257,10 @@
}
/* samples playd, it remains */
*osamp = done;
- return (ST_SUCCESS);
+ if (phaser->fade_out == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
/*
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -113,7 +113,7 @@
if (repeat->remaining == 0) {
if (repeat->repeats == 0) {
*osamp = 0;
- return (ST_SUCCESS);
+ return (ST_EOF);
}
else {
repeat->repeats--;
@@ -180,7 +180,10 @@
repeat->remaining -= *osamp;
}
- return (ST_SUCCESS);
+ if (repeat->remaining == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
int st_repeat_stop(eff_t effp)
--- a/src/reverse.c
+++ b/src/reverse.c
@@ -126,7 +126,10 @@
obuf[j] = temp;
}
*osamp = len;
- return(ST_SUCCESS);
+ if (reverse->pos == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
/*
--- a/src/silence.c
+++ b/src/silence.c
@@ -677,7 +677,10 @@
}
*osamp = nrOfOutSamplesWritten;
- return(ST_SUCCESS);
+ if (silence->mode == SILENCE_STOP || *osamp == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
int st_silence_stop(eff_t effp)
--- a/src/sox.c
+++ b/src/sox.c
@@ -157,6 +157,7 @@
static struct st_effect efftabR[MAX_EFF];/* right channel effects */
static int neffects; /* # of effects to run on data */
static int input_eff; /* last input effect with data */
+static int input_eff_eof; /* has input_eff reached EOF? */
static struct st_effect user_efftab[MAX_USER_EFF];
static int nuser_effects;
@@ -595,6 +596,7 @@
file_desc[f]->st_errno = 0;
input_eff = 0;
+ input_eff_eof = 0;
/* mark chain as empty */
for(e = 1; e < neffects; e++)
@@ -1051,6 +1053,13 @@
/* this is because buffering system isn't a nice queueing system */
for(e = neffects - 1; e >= input_eff; e--)
{
+ /* Do not call flow effect on input if its reported
+ * EOF already as thats a waste of time and may
+ * do bad things.
+ */
+ if (e == input_eff && input_eff_eof)
+ continue;
+
/* flow_effect returns ST_EOF when it will not process
* any more samples. This is used to bail out early.
* Since we are "pulling" data, it is OK that we are not
@@ -1059,7 +1068,11 @@
*/
flowstatus = flow_effect(e);
if (flowstatus == ST_EOF)
+ {
input_eff = e+1;
+ /* Assume next effect hasn't reach EOF yet */
+ input_eff_eof = 0;
+ }
/* If this buffer contains more input data then break out
* of this loop now. This will allow us to loop back around
@@ -1173,11 +1186,16 @@
rc = drain_effect(input_eff);
- if (rc == ST_EOF || efftab[input_eff].olen == 0)
+ if (efftab[input_eff].olen == 0)
+ {
input_eff++;
+ /* Assume next effect hasn't reached EOF yet. */
+ input_eff_eof = 0;
+ }
else
{
havedata = 1;
+ input_eff_eof = (rc == ST_EOF) ? 1 : 0;
break;
}
}
@@ -1314,7 +1332,11 @@
{
/* Skip past input effect since we know thats not needed */
if (input_eff == 0)
+ {
input_eff = 1;
+ /* Assuming next effect hasn't reached EOF yet. */
+ input_eff_eof = 0;
+ }
/* Try to prime the pump with some data */
while (input_eff < neffects)
@@ -1323,10 +1345,17 @@
rc = drain_effect(input_eff);
- if (rc == ST_EOF || efftab[input_eff].olen == 0)
+ if (efftab[input_eff].olen == 0)
+ {
input_eff++;
+ /* Assuming next effect hasn't reached EOF yet. */
+ input_eff_eof = 0;
+ }
else
+ {
+ input_eff_eof = (rc == ST_EOF) ? 1 : 0;
break;
+ }
}
/* Just do standard flow routines after the priming. */