ref: 7ca19868aa8675d25238f7688b5c981abbff1778
parent: 0547ae09bf167e88af132c5a23dbf93438dd919b
author: Ulrich Klauer <ulrich@chirlu.de>
date: Sun Jan 1 20:49:09 EST 2012
repeat effect: pass through audio on first pass repeat would wait for the complete audio to be stored in a temporary file and only then pass it on to the next effect. Passing it through directly is not much work and has the advantage that especially playback can begin immediately.
--- a/src/repeat.c
+++ b/src/repeat.c
@@ -44,7 +44,7 @@
return SOX_EOF;
}
p->num_samples = p->remaining_samples = 0;
- p->remaining_repeats = p->num_repeats + 1;
+ p->remaining_repeats = p->num_repeats;
return SOX_SUCCESS;
}
@@ -52,12 +52,14 @@
sox_sample_t * obuf, size_t * isamp, size_t * osamp)
{
priv_t * p = (priv_t *)effp->priv;
- if (fwrite(ibuf, sizeof(*ibuf), *isamp, p->tmp_file) != *isamp) {
+ size_t len = min(*isamp, *osamp);
+ memcpy(obuf, ibuf, len * sizeof(*obuf));
+ if (fwrite(ibuf, sizeof(*ibuf), len, p->tmp_file) != len) {
lsx_fail("error writing temporary file: %s", strerror(errno));
return SOX_EOF;
}
- p->num_samples += *isamp;
- (void)obuf, *osamp = 0; /* samples not output until drain */
+ p->num_samples += len;
+ *isamp = *osamp = len;
return SOX_SUCCESS;
}