When using the "output" effect, as in example0.c, if the output is an ogg file, the call to sox_flow_effects takes very long time to return (~35s on my machine for 2 minutes of sound data).
By contrast, doing the same conversion using the sox binary is very fast (~2s). It seems to me it is because sox.c doesn't use the "output" effect but rather implements its own (output_effect_fn).
I believe the problem is that in the output effect, the flow() function calls sox_write() even when the length of the data is 0, and the vorbis encoder does not handle that well. The output_effect_fn in sox.c checks for null-length buffer (in output_flow()) and doesn't call sox_write() unless there is any data to write.
This should probably be fixed in output.c, maybe by adding something like this to the beginning of flow():
if (isamp == 0) {
osamp = 0;
return SOX_SUCCESS;
}
Thanks. The suggested fix is perfect, modulo
*isampand*osamphttps://codeberg.org/sox_ng/sox_ng/issues/545
Last edit: Martin Guy 2025-08-07