Commit 48133110 authored by Erik de Castro Lopo's avatar Erik de Castro Lopo
Browse files

src/flac/main.c : Change the default beahviour when compression fails.

Previously the flac executable would return a non-zero exit code when the
output file was bigger than the input file and this could be disabled with
the --no-error-on-compression-fail option.

New beaviour is to print the failure message but return a zero exit code
in the above situation, and only return a non-zero exit code with the
--error--on-compression-fail option. The --no-error-on-compression-fail
command line option has been retained.
parent 37a97a59
......@@ -1653,7 +1653,7 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a
}
}
if (error_on_compression_fail && e->compression_ratio >= 1.0) {
if (e->compression_ratio >= 1.0) {
flac__utils_printf(stderr, 1,
"FAILURE: Compression failed (ratio %0.3f, should be < 1.0).\n"
"This happens for some files for one or more of the following reasons:\n"
......@@ -1661,7 +1661,8 @@ int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_a
" * Insufficient input data (eg, very short files, < 10000 fames).\n"
" * The audio data is not compressable (eg a full range white noise signal).\n"
, e->compression_ratio);
ret = 1;
if (error_on_compression_fail)
ret = 1;
}
EncoderSession_destroy(e);
......
......@@ -173,6 +173,7 @@ static struct share__option long_options_[] = {
{ "sample-rate" , share__required_argument, 0, 0 },
{ "sign" , share__required_argument, 0, 0 },
{ "input-size" , share__required_argument, 0, 0 },
{ "error-on-compression-fail" , share__no_argument, 0, 0 },
/*
* analysis options
......@@ -596,7 +597,7 @@ FLAC__bool init_options(void)
option_values.cuesheet_filename = 0;
option_values.cued_seekpoints = true;
option_values.channel_map_none = false;
option_values.error_on_compression_fail = true;
option_values.error_on_compression_fail = false;
option_values.num_files = 0;
option_values.filenames = 0;
......@@ -914,6 +915,9 @@ int parse_option(int short_option, const char *long_option, const char *option_a
else if(0 == strcmp(long_option, "no-error-on-compression-fail")) {
option_values.error_on_compression_fail = false;
}
else if(0 == strcmp(long_option, "error-on-compression-fail")) {
option_values.error_on_compression_fail = true;
}
}
else {
switch(short_option) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment