ref: f43e5e352291d69d2a4dad8e3fb11d66f8dc938c
parent: 1b48206ecf97b974de54ca01378d2706ce92953c
author: Ulrich Klauer <ulrich@chirlu.de>
date: Fri Jan 13 16:15:10 EST 2012
Fail if an MCHAN effect is splitting wide samples Check that a SOX_EFF_MCHAN effect only processes complete wide samples and fail if it does otherwise. While splitting wide samples between flow or drain invokations might be OK in certain cases, it isn't necessary and is prone to bugs that are hopefully discovered earlier now.
--- a/src/effects.c
+++ b/src/effects.c
@@ -225,6 +225,10 @@
idone -= idone % effp->in_signal.channels;
effstatus = effp->handler.flow(effp, &effp1->obuf[effp1->obeg],
&effp->obuf[effp->oend], &idone, &obeg);
+ if (obeg % effp->out_signal.channels != 0) {
+ lsx_fail("multi-channel effect flowed asymmetrically!");
+ effstatus = SOX_EOF;
+ }
} else { /* Run effect on each channel individually */
sox_sample_t *obuf = &effp->obuf[effp->oend];
size_t idone_last = 0, odone_last = 0; /* Initialised to prevent warning */
@@ -307,9 +311,13 @@
size_t pre_odone = obeg;
#endif
- if (effp->flows == 1) /* Run effect on all channels at once */
+ if (effp->flows == 1) { /* Run effect on all channels at once */
effstatus = effp->handler.drain(effp, &effp->obuf[effp->oend], &obeg);
- else { /* Run effect on each channel individually */
+ if (obeg % effp->out_signal.channels != 0) {
+ lsx_fail("multi-channel effect drained asymmetrically!");
+ effstatus = SOX_EOF;
+ }
+ } else { /* Run effect on each channel individually */
sox_sample_t *obuf = &effp->obuf[effp->oend];
size_t odone_last = 0; /* Initialised to prevent warning */