ref: 95bf3e94e076ec9f7dd7a39ab5a4d0423edd87f2
parent: 1b53d0c746a5de122278d0dcfc4d25fd0a7f25bb
author: Ulrich Klauer <[email protected]>
date: Wed Jan 18 19:45:21 EST 2012
Calculate input length for multiple files Properly calculate the input length (output length of the combiner effect) even for multiple files, except when in sox_sequence mode.
--- a/src/sox.c
+++ b/src/sox.c
@@ -1620,6 +1620,7 @@
size_t max_channels = 0;
size_t min_rate = SOX_SIZE_MAX;
size_t max_rate = 0;
+ uint64_t total_length = 0, max_length = 0;
/* Report all input files and gather info on differing rates & numbers of
* channels, and on the resulting output audio length: */
@@ -1630,6 +1631,11 @@
max_channels = max(max_channels, files[i]->ft->signal.channels);
min_rate = min(min_rate , files[i]->ft->signal.rate);
max_rate = max(max_rate , files[i]->ft->signal.rate);
+ max_length = max(max_length , files[i]->ft->signal.length);
+ if (total_length != SOX_UNKNOWN_LEN && files[i]->ft->signal.length)
+ total_length += files[i]->ft->signal.length;
+ else
+ total_length = SOX_UNKNOWN_LEN;
}
/* Check for invalid/unusual rate or channel combinations: */
@@ -1645,6 +1651,11 @@
}
if (min_rate != max_rate)
exit(1);
+
+ if (combine_method == sox_concatenate)
+ combiner_signal.length = total_length;
+ else if (is_parallel(combine_method))
+ combiner_signal.length = max_length;
/* Store the calculated # of combined channels: */
combiner_signal.channels =