ref: fdc86daca0c63d0ac4d4744e69c41a839977ecb0
parent: 0f74930593ba0568b1f13918d61d90b58cddb3ba
author: cbagwell <cbagwell>
date: Tue Feb 21 21:24:58 EST 2006
Initial pass at making all drain()'s return ST_EOF when no more data.
--- a/src/compand.c
+++ b/src/compand.c
@@ -378,7 +378,11 @@
/* tell caller number of samples played */
*osamp = done;
- return (ST_SUCCESS);
+
+ if (l->delay_buf_cnt > 0)
+ return ST_SUCCESS;
+ else
+ return ST_EOF;
}
--- a/src/deemphas.c
+++ b/src/deemphas.c
@@ -118,12 +118,12 @@
if (n)
{
st_fail("Deemphasis filtering effect takes no options.\n");
- return (ST_EOF);
+ return (ST_EOF);
}
if (sizeof(double)*ST_MAX_EFFECT_PRIVSIZE < sizeof(struct deemphstuff))
{
st_fail("Internal error: PRIVSIZE too small.\n");
- return (ST_EOF);
+ return (ST_EOF);
}
return (ST_SUCCESS);
}
@@ -142,7 +142,7 @@
st_fail("The deemphasis effect works only with audio cd like samples.\nThe input format however has %d Hz sample rate and %d-byte%s signed linearly coded samples.",
effp->ininfo.rate, effp->ininfo.size,
effp->ininfo.encoding != ST_ENCODING_SIGN2 ? ", but not" : "");
- return (ST_EOF);
+ return (ST_EOF);
}
else
{
@@ -190,7 +190,7 @@
int st_deemph_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
/* nothing to do */
- return (ST_SUCCESS);
+ return (ST_EOF);
}
/*
--- a/src/filter.c
+++ b/src/filter.c
@@ -266,7 +266,7 @@
/* fprintf(stderr,"DRAIN osamp %d\n", *osamp); */
if (isamp_res)
st_warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
- /* This is very picky. osamp better be big enough to grab
+ /* FIXME: This is very picky. osamp better be big enough to grab
* all remaining samples or they will be discarded.
*/
return (ST_EOF);
--- a/src/mcompand.c
+++ b/src/mcompand.c
@@ -663,7 +663,11 @@
}
*osamp = mostdrained;
- return (ST_SUCCESS);
+
+ if (mostdrained)
+ return ST_SUCCESS;
+ else
+ return ST_EOF;
}
/*
--- a/src/misc.c
+++ b/src/misc.c
@@ -361,7 +361,8 @@
/* dummy effect routine for do-nothing functions */
int st_effect_nothing(eff_t effp) { return(ST_SUCCESS); }
-int st_effect_nothing_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp) { *osamp = 0; return(ST_SUCCESS); }
+int st_effect_nothing_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
+ { /* Inform no more samples to drain */ *osamp = 0; return(ST_EOF); }
/* here for linear interp. might be useful for other things */
st_sample_t st_gcd(st_sample_t a, st_sample_t b)
--- a/src/noiseprof.c
+++ b/src/noiseprof.c
@@ -159,7 +159,7 @@
*osamp = 0;
if (data->bufdata == 0) {
- return ST_SUCCESS;
+ return ST_EOF;
}
for (i = 0; i < tracks; i ++) {
@@ -169,8 +169,11 @@
}
collect_data(data, &(data->chandata[i]));
}
-
- return (ST_SUCCESS);
+
+ if (data->bufdata == WINDOWSIZE || data->bufdata == 0)
+ return ST_EOF;
+ else
+ return ST_SUCCESS;
}
/*
--- a/src/noisered.c
+++ b/src/noisered.c
@@ -312,7 +312,7 @@
for (i = 0; i < tracks; i ++) {
*osamp = process_window(data, i, tracks, obuf, data->bufdata);
}
- /* This is very picky. osamp needs to be big enough to get all
+ /* FIXME: This is very picky. osamp needs to be big enough to get all
* remaining data or it will be discarded.
*/
return (ST_EOF);
--- a/src/resample.c
+++ b/src/resample.c
@@ -401,6 +401,9 @@
/* fprintf(stderr,"DRAIN osamp %d\n", *osamp); */
if (isamp_res)
st_warn("drain overran obuf by %d\n", isamp_res); fflush(stderr);
+ /* FIXME: This is very picky. IF obuf is not big enough to
+ * drain remaining samples, they will be lost.
+ */
return (ST_EOF);
}
--- a/src/skeleff.c
+++ b/src/skeleff.c
@@ -15,7 +15,7 @@
/* Private data for SKEL file */
typedef struct skelleffstuff {
- int localdata;
+ int localdata;
} *skeleff_t;
/*
@@ -30,11 +30,11 @@
if (n)
{
- if (n != 1)
- {
- st_fail("Usage: skeleff [option]");
- return (ST_EOF);
- }
+ if (n != 1)
+ {
+ st_fail("Usage: skeleff [option]");
+ return (ST_EOF);
+ }
}
return (ST_SUCCESS);
}
@@ -47,8 +47,8 @@
{
if (effp->outinfo.channels == 1)
{
- st_fail("Can't run skeleff on mono data.");
- return (ST_EOF);
+ st_fail("Can't run skeleff on mono data.");
+ return (ST_EOF);
}
return (ST_SUCCESS);
}
@@ -66,24 +66,24 @@
switch (effp->outinfo.channels)
{
case 2:
- /* Length to process will be buffer length / 2 since we
- * work with two samples at a time.
- */
- len = ((*isamp > *osamp) ? *osamp : *isamp) / 2;
- for(done = 0; done < len; done++)
- {
- obuf[0] = ibuf[0];
- obuf[1] = ibuf[1];
- /* Advance buffer by 2 samples */
- ibuf += 2;
- obuf += 2;
- }
-
- *isamp = len * 2;
- *osamp = len * 2;
-
- break;
-
+ /* Length to process will be buffer length / 2 since we
+ * work with two samples at a time.
+ */
+ len = ((*isamp > *osamp) ? *osamp : *isamp) / 2;
+ for(done = 0; done < len; done++)
+ {
+ obuf[0] = ibuf[0];
+ obuf[1] = ibuf[1];
+ /* Advance buffer by 2 samples */
+ ibuf += 2;
+ obuf += 2;
+ }
+
+ *isamp = len * 2;
+ *osamp = len * 2;
+
+ break;
+
}
return (ST_SUCCESS);
}
@@ -94,16 +94,20 @@
int st_skeleff_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
- *osamp = 0;
- return (ST_SUCCESS);
+ *osamp = 0;
+ /* Help out application and return ST_EOF when drain
+ * will not return any mre information. *osamp == 0
+ * also indicates that.
+ */
+ return (ST_EOF);
}
/*
* Do anything required when you stop reading samples.
- * (free allocated memory, etc.)
+ * (free allocated memory, etc.)
*/
int st_skeleff_stop(eff_t effp)
{
- /* nothing to do */
+ /* nothing to do */
return (ST_SUCCESS);
}
--- a/src/stat.c
+++ b/src/stat.c
@@ -305,7 +305,7 @@
}
*osamp = 0;
- return (ST_SUCCESS);
+ return (ST_EOF);
}
/*
--- a/src/swap.c
+++ b/src/swap.c
@@ -183,8 +183,8 @@
int st_swap_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
- *osamp = 0;
- return (ST_SUCCESS);
+ *osamp = 0;
+ return ST_EOF;
}
/*
--- a/src/synth.c
+++ b/src/synth.c
@@ -743,8 +743,8 @@
int st_synth_drain(eff_t effp, st_sample_t *obuf, st_size_t *osamp)
{
- *osamp = 0;
- return (ST_SUCCESS);
+ *osamp = 0;
+ return ST_EOF;
}
/*