Error handling: don't continue with zero or negative ratio; don't continue if input file lacks sample rate. Both cases will be caught by subsequent calls anyway (e.g. in sf_open) but only with more confusing error reporting
This commit is contained in:
@@ -267,6 +267,11 @@ int main(int argc, char **argv)
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ratio <= 0.0) {
|
||||||
|
cerr << "ERROR: Invalid time ratio " << ratio << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (crispness >= 0 && crispchanged) {
|
if (crispness >= 0 && crispchanged) {
|
||||||
cerr << "WARNING: Both crispness option and transients, lamination or window options" << endl;
|
cerr << "WARNING: Both crispness option and transients, lamination or window options" << endl;
|
||||||
cerr << " provided -- crispness will override these other options" << endl;
|
cerr << " provided -- crispness will override these other options" << endl;
|
||||||
@@ -345,6 +350,7 @@ int main(int argc, char **argv)
|
|||||||
SF_INFO sfinfo;
|
SF_INFO sfinfo;
|
||||||
SF_INFO sfinfoOut;
|
SF_INFO sfinfoOut;
|
||||||
memset(&sfinfo, 0, sizeof(SF_INFO));
|
memset(&sfinfo, 0, sizeof(SF_INFO));
|
||||||
|
memset(&sfinfoOut, 0, sizeof(SF_INFO));
|
||||||
|
|
||||||
sndfile = sf_open(fileName, SFM_READ, &sfinfo);
|
sndfile = sf_open(fileName, SFM_READ, &sfinfo);
|
||||||
if (!sndfile) {
|
if (!sndfile) {
|
||||||
@@ -353,9 +359,14 @@ int main(int argc, char **argv)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (sfinfo.samplerate == 0) {
|
||||||
|
cerr << "ERROR: File lacks sample rate in header" << endl;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (duration != 0.0) {
|
if (duration != 0.0) {
|
||||||
if (sfinfo.frames == 0 || sfinfo.samplerate == 0) {
|
if (sfinfo.frames == 0) {
|
||||||
cerr << "ERROR: File lacks frame count or sample rate in header, cannot use --duration" << endl;
|
cerr << "ERROR: File lacks frame count in header, cannot use --duration" << endl;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
double induration = double(sfinfo.frames) / double(sfinfo.samplerate);
|
double induration = double(sfinfo.frames) / double(sfinfo.samplerate);
|
||||||
|
|||||||
Reference in New Issue
Block a user