- --import-picture-from=SPECIFICATION
+ --import-picture-from={FILENAME|SPECIFICATION}
Import a picture and store it in a PICTURE metadata block. See the flac option --picture for an explanation of the SPECIFICATION syntax.
diff --git a/man/flac.sgml b/man/flac.sgml
index 07789aef..ef6a65d5 100644
--- a/man/flac.sgml
+++ b/man/flac.sgml
@@ -157,6 +157,14 @@
+
+ -w , --warnings-as-errors
+
+
+ Treat all warnings as errors (which cause flac to terminate with a non-zero exit code).
+
+
+
-f , --force
@@ -303,11 +311,11 @@
- --picture =SPECIFICATION
+ --picture ={FILENAME |SPECIFICATION }
- Import a picture and store it in a PICTURE metadata block. More than one --picture command can be specified. The SPECIFICATION is a string whose parts are separated by | (pipe) characters. Some parts may be left empty to invoke default values. The format of SPECIFICATION is
- [TYPE]|MIME-TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE
+ Import a picture and store it in a PICTURE metadata block. More than one --picture command can be specified. Either a filename for the picture file or a more complete specification form can be used. The SPECIFICATION is a string whose parts are separated by | (pipe) characters. Some parts may be left empty to invoke default values. FILENAME is just shorthand for "||||FILENAME". The format of SPECIFICATION is
+ [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE
TYPE is optional; it is a number from one of:
0: Other
1: 32x32 pixels 'file icon' (PNG only)
@@ -332,7 +340,7 @@
20: Publisher/Studio logotype
The default is 3 (front cover). There may only be one picture each of type 1 and 2 in a file.
- MIME-TYPE is mandatory; for best compatibility with players, use pictures with MIME type image/jpeg or image/png. The MIME type can also be --> to mean that FILE is actually a URL to an image, though this use is discouraged.
+ MIME-TYPE is optional; if left blank, it will be detected from the file. For best compatibility with players, use pictures with MIME type image/jpeg or image/png. The MIME type can also be --> to mean that FILE is actually a URL to an image, though this use is discouraged.
DESCRIPTION is optional; the default is an empty string.
@@ -656,6 +664,7 @@
--no-seektable
--no-silent
--no-verify
+ --no-warnings-as-errors
These flags can be used to invert the sense of the corresponding normal option.
diff --git a/src/flac/decode.c b/src/flac/decode.c
index 35d47e47..5ac21aaf 100644
--- a/src/flac/decode.c
+++ b/src/flac/decode.c
@@ -49,6 +49,7 @@ typedef struct {
FLAC__bool is_aiff_out;
FLAC__bool is_wave_out;
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors;
FLAC__bool channel_map_none;
@@ -102,7 +103,7 @@ static FLAC__bool is_big_endian_host_;
/*
* local routines
*/
-static FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename);
+static FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename);
static void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred);
static FLAC__bool DecoderSession_init_decoder(DecoderSession *d, decode_options_t decode_options, const char *infilename);
static FLAC__bool DecoderSession_process(DecoderSession *d);
@@ -141,6 +142,7 @@ int flac__decode_aiff(const char *infilename, const char *outfilename, FLAC__boo
#endif
/*is_aiff_out=*/true,
/*is_wave_out=*/false,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
options.common.channel_map_none,
options.common.replaygain_synthesis_spec,
@@ -178,6 +180,7 @@ int flac__decode_wav(const char *infilename, const char *outfilename, FLAC__bool
#endif
/*is_aiff_out=*/false,
/*is_wave_out=*/true,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
options.common.channel_map_none,
options.common.replaygain_synthesis_spec,
@@ -218,6 +221,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
#endif
/*is_aiff_out=*/false,
/*is_wave_out=*/false,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
options.common.channel_map_none,
options.common.replaygain_synthesis_spec,
@@ -241,7 +245,7 @@ int flac__decode_raw(const char *infilename, const char *outfilename, FLAC__bool
return DecoderSession_finish_ok(&decoder_session);
}
-FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename)
+FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FLAC__bool channel_map_none, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename)
{
#if FLAC__HAS_OGG
d->is_ogg = is_ogg;
@@ -251,6 +255,7 @@ FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__
d->is_aiff_out = is_aiff_out;
d->is_wave_out = is_wave_out;
+ d->treat_warnings_as_errors = treat_warnings_as_errors;
d->continue_through_decode_errors = continue_through_decode_errors;
d->channel_map_none = channel_map_none;
d->replaygain.spec = replaygain_synthesis_spec;
@@ -470,9 +475,11 @@ int DecoderSession_finish_ok(DecoderSession *d)
else {
if(!d->got_stream_info) {
flac__utils_printf(stderr, 1, "\r%s: WARNING, cannot check MD5 signature since there was no STREAMINFO\n", d->inbasefilename);
+ ok = !d->treat_warnings_as_errors;
}
else if(!d->has_md5sum) {
flac__utils_printf(stderr, 1, "\r%s: WARNING, cannot check MD5 signature since it was unset in the STREAMINFO\n", d->inbasefilename);
+ ok = !d->treat_warnings_as_errors;
}
flac__utils_printf(stderr, 2, "\r%s: %s \n", d->inbasefilename, d->test_only? "ok ":d->analysis_mode?"done ":"done");
}
@@ -551,6 +558,8 @@ FLAC__bool write_iff_headers(FILE *f, DecoderSession *decoder_session, FLAC__uin
flac__utils_printf(stderr, 1, "%s: WARNING, don't have accurate sample count available for %s header.\n", decoder_session->inbasefilename, fmt_desc);
flac__utils_printf(stderr, 1, " Generated %s file will have a data chunk size of 0. Try\n", fmt_desc);
flac__utils_printf(stderr, 1, " decoding directly to a file instead.\n");
+ if(decoder_session->treat_warnings_as_errors)
+ return false;
}
else {
decoder_session->iff_headers_need_fixup = true;
@@ -1076,6 +1085,10 @@ void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMet
double reference, gain, peak;
if (!(decoder_session->replaygain.apply = grabbag__replaygain_load_from_vorbiscomment(metadata, decoder_session->replaygain.spec.use_album_gain, /*strict=*/false, &reference, &gain, &peak))) {
flac__utils_printf(stderr, 1, "%s: WARNING: can't get %s (or even %s) ReplayGain tags\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track", decoder_session->replaygain.spec.use_album_gain? "track":"album");
+ if(decoder_session->treat_warnings_as_errors) {
+ decoder_session->abort_flag = true;
+ return;
+ }
}
else {
const char *ls[] = { "no", "peak", "hard" };
@@ -1085,6 +1098,7 @@ void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMet
FLAC__replaygain_synthesis__init_dither_context(&decoder_session->replaygain.dither_context, decoder_session->bps, decoder_session->replaygain.spec.noise_shaping);
flac__utils_printf(stderr, 1, "%s: INFO: applying %s ReplayGain (gain=%0.2fdB+preamp=%0.1fdB, %s noise shaping, %s limiting) to output\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track", gain, decoder_session->replaygain.spec.preamp, ns[decoder_session->replaygain.spec.noise_shaping], ls[decoder_session->replaygain.spec.limiter]);
flac__utils_printf(stderr, 1, "%s: WARNING: applying ReplayGain is not lossless\n", decoder_session->inbasefilename);
+ /* don't check if(decoder_session->treat_warnings_as_errors) because the user explicitly asked for it */
}
}
(void)flac__utils_get_channel_mask_tag(metadata, &decoder_session->channel_mask);
diff --git a/src/flac/decode.h b/src/flac/decode.h
index 0b862134..2d3c3aef 100644
--- a/src/flac/decode.h
+++ b/src/flac/decode.h
@@ -36,6 +36,7 @@ typedef struct {
} replaygain_synthesis_spec_t;
typedef struct {
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors;
replaygain_synthesis_spec_t replaygain_synthesis_spec;
#if FLAC__HAS_OGG
diff --git a/src/flac/encode.c b/src/flac/encode.c
index 50d7e7ae..29cd14af 100644
--- a/src/flac/encode.c
+++ b/src/flac/encode.c
@@ -67,6 +67,7 @@ typedef struct {
FLAC__uint64 skip;
FLAC__uint64 until; /* a value of 0 mean end-of-stream (i.e. --until=-0) */
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors;
FLAC__bool replay_gain;
unsigned channels;
@@ -119,7 +120,7 @@ extern FLAC__bool FLAC__stream_encoder_disable_verbatim_subframes(FLAC__StreamEn
/*
* local routines
*/
-static FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename);
+static FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename);
static void EncoderSession_destroy(EncoderSession *e);
static int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero);
static int EncoderSession_finish_error(EncoderSession *e);
@@ -138,7 +139,7 @@ static FLAC__bool flac_decoder_eof_callback(const FLAC__StreamDecoder *decoder,
static FLAC__StreamDecoderWriteStatus flac_decoder_write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data);
static void flac_decoder_metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data);
static void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data);
-static FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);
+static FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors);
static void print_stats(const EncoderSession *encoder_session);
static void print_error_with_init_status(const EncoderSession *e, const char *message, FLAC__StreamEncoderInitStatus init_status);
static void print_error_with_state(const EncoderSession *e, const char *message);
@@ -179,6 +180,7 @@ int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, con
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
@@ -221,6 +223,8 @@ int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, con
}
else if(!is_aifc && xx!=minimum_comm_size) {
flac__utils_printf(stderr, 1, "%s: WARNING: non-standard %s 'COMM' chunk has length = %u, expected %u\n", encoder_session.inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx, minimum_comm_size);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
skip= (xx-minimum_comm_size)+(xx & 1U);
@@ -451,6 +455,8 @@ int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, con
}
else if(feof(infile)) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
data_bytes= 0;
}
}
@@ -511,6 +517,8 @@ int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, con
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_frame) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)bytes_read, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
info_align_carry= *options.common.align_reservoir_samples;
@@ -535,12 +543,18 @@ int flac__encode_aif(FILE *infile, off_t infilesize, const char *infilename, con
else { /* other chunk */
if(!memcmp(chunk_id, "COMM", 4)) {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'COMM' chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else if(!memcmp(chunk_id, "SSND", 4)) {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'SSND' chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk '%s'\n", encoder_session.inbasefilename, chunk_id);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
/* chunk size */
@@ -592,6 +606,7 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
@@ -705,6 +720,8 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
if(bps == 24 || bps == 32) {
/* let these slide with a warning since they're unambiguous */
flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file has format type %u but bits-per-sample=%u\n", encoder_session.inbasefilename, (unsigned)format, bps);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
/* @@@ we could add an option to specify left- or right-justified blocks so we knew how to set 'shift' */
@@ -717,6 +734,8 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
if(bps % 8) {
/* assume legacy file is byte aligned with some LSBs zero; this is double-checked in format_input() */
flac__utils_printf(stderr, 1, "%s: WARNING: legacy WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", encoder_session.inbasefilename, (unsigned)format, block_align, bps, channels);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
shift = 8 - (bps % 8);
bps += shift;
}
@@ -972,6 +991,8 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
}
else if(feof(infile)) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
data_bytes = 0;
}
}
@@ -1031,6 +1052,8 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
info_align_carry = *options.common.align_reservoir_samples;
@@ -1055,10 +1078,14 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
else {
if(xx == 0x20746d66 && got_fmt_chunk) { /* "fmt " */
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'fmt ' sub-chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else if(xx == 0x61746164) { /* "data" */
if(got_data_chunk) {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'data' sub-chunk\n", encoder_session.inbasefilename);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else if(!got_fmt_chunk) {
flac__utils_printf(stderr, 1, "%s: ERROR: got 'data' sub-chunk before 'fmt' sub-chunk\n", encoder_session.inbasefilename);
@@ -1070,6 +1097,8 @@ int flac__encode_wav(FILE *infile, off_t infilesize, const char *infilename, con
}
else {
flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown sub-chunk '%c%c%c%c'\n", encoder_session.inbasefilename, (char)(xx&255), (char)((xx>>8)&255), (char)((xx>>16)&255), (char)(xx>>24));
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
/* sub-chunk size */
if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
@@ -1114,6 +1143,7 @@ int flac__encode_raw(FILE *infile, off_t infilesize, const char *infilename, con
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
@@ -1287,6 +1317,8 @@ int flac__encode_raw(FILE *infile, off_t infilesize, const char *infilename, con
}
else if(feof(infile)) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
total_input_bytes_read = max_input_bytes;
}
}
@@ -1339,6 +1371,8 @@ int flac__encode_raw(FILE *infile, off_t infilesize, const char *infilename, con
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned)bytes_read, (unsigned)encoder_session.total_samples_to_encode, (unsigned)encoder_session.samples_written);
+ if(encoder_session.treat_warnings_as_errors)
+ return EncoderSession_finish_error(&encoder_session);
}
else {
info_align_carry = *options.common.align_reservoir_samples;
@@ -1369,6 +1403,7 @@ int flac__encode_flac(FILE *infile, off_t infilesize, const char *infilename, co
/*use_ogg=*/false,
#endif
options.common.verify,
+ options.common.treat_warnings_as_errors,
options.common.continue_through_decode_errors,
infile,
infilename,
@@ -1518,7 +1553,7 @@ fubar1:
return EncoderSession_finish_error(&encoder_session);
}
-FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename)
+FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool treat_warnings_as_errors, FLAC__bool continue_through_decode_errors, FILE *infile, const char *infilename, const char *outfilename)
{
unsigned i;
FLAC__uint32 test = 1;
@@ -1543,6 +1578,7 @@ FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC_
(void)use_ogg;
#endif
e->verify = verify;
+ e->treat_warnings_as_errors = treat_warnings_as_errors;
e->continue_through_decode_errors = continue_through_decode_errors;
e->is_stdout = (0 == strcmp(outfilename, "-"));
@@ -1688,7 +1724,7 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
}
}
- if(!parse_cuesheet(&cuesheet, options.cuesheet_filename, e->inbasefilename, is_cdda, e->total_samples_to_encode))
+ if(!parse_cuesheet(&cuesheet, options.cuesheet_filename, e->inbasefilename, is_cdda, e->total_samples_to_encode, e->treat_warnings_as_errors))
return false;
if(!convert_to_seek_table_template(options.requested_seek_points, options.num_requested_seek_points, options.cued_seekpoints? cuesheet : 0, e)) {
@@ -1736,6 +1772,11 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_VORBIS_COMMENT && options.vorbis_comment->data.vorbis_comment.num_comments > 0) {
(void) flac__utils_get_channel_mask_tag(flac_decoder_data->metadata_blocks[i], &channel_mask);
flac__utils_printf(stderr, 1, "%s: WARNING, replacing tags from input FLAC file with those given on the command-line\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]);
flac_decoder_data->metadata_blocks[i] = 0;
}
@@ -1772,16 +1813,31 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
const FLAC__StreamMetadata_CueSheet *cs = &flac_decoder_data->metadata_blocks[i]->data.cue_sheet;
if(e->total_samples_to_encode == 0) {
flac__utils_printf(stderr, 1, "%s: WARNING, cuesheet in input FLAC file cannot be kept if input size is not known, dropping it...\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
existing_cuesheet_is_bad = true;
}
else if(e->total_samples_to_encode != cs->tracks[cs->num_tracks-1].offset) {
flac__utils_printf(stderr, 1, "%s: WARNING, lead-out offset of cuesheet in input FLAC file does not match input length, dropping existing cuesheet...\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
existing_cuesheet_is_bad = true;
}
}
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_CUESHEET && (existing_cuesheet_is_bad || 0 != cuesheet)) {
- if(0 != cuesheet)
+ if(0 != cuesheet) {
flac__utils_printf(stderr, 1, "%s: WARNING, replacing cuesheet in input FLAC file with the one given on the command-line\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
+ }
FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]);
flac_decoder_data->metadata_blocks[i] = 0;
}
@@ -1823,12 +1879,24 @@ FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t optio
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_SEEKTABLE)
existing_seektable = true;
if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_SEEKTABLE && (e->total_samples_to_encode != flac_decoder_data->metadata_blocks[0]->data.stream_info.total_samples || options.num_requested_seek_points >= 0)) {
- if(options.num_requested_seek_points > 0)
+ if(options.num_requested_seek_points > 0) {
flac__utils_printf(stderr, 1, "%s: WARNING, replacing seektable in input FLAC file with the one given on the command-line\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
+ }
else if(options.num_requested_seek_points == 0)
; /* no warning, silently delete existing SEEKTABLE since user specified --no-seektable (-S-) */
- else
+ else {
flac__utils_printf(stderr, 1, "%s: WARNING, can't use existing seektable in input FLAC since the input size is changing or unknown, dropping existing SEEKTABLE block...\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors) {
+ if(0 != cuesheet)
+ FLAC__metadata_object_delete(cuesheet);
+ return false;
+ }
+ }
FLAC__metadata_object_delete(flac_decoder_data->metadata_blocks[i]);
flac_decoder_data->metadata_blocks[i] = 0;
existing_seektable = false;
@@ -2045,6 +2113,8 @@ FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const b
if(e->replay_gain) {
if(!grabbag__replaygain_analyze(buffer, e->channels==2, e->bits_per_sample, samples)) {
flac__utils_printf(stderr, 1, "%s: WARNING, error while calculating ReplayGain\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors)
+ return false;
}
}
@@ -2088,6 +2158,8 @@ FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int
if(has_real_points) {
if(e->is_stdout) {
flac__utils_printf(stderr, 1, "%s: WARNING, cannot write back seekpoints when encoding to stdout\n", e->inbasefilename);
+ if(e->treat_warnings_as_errors)
+ return false;
}
}
@@ -2412,7 +2484,7 @@ void flac_decoder_error_callback(const FLAC__StreamDecoder *decoder, FLAC__Strea
data->fatal_error = true;
}
-FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset)
+FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool treat_warnings_as_errors)
{
FILE *f;
unsigned last_line_read;
@@ -2448,6 +2520,8 @@ FLAC__bool parse_cuesheet(FLAC__StreamMetadata **cuesheet, const char *cuesheet_
/* if we're expecting CDDA, warn about non-compliance */
if(is_cdda && !FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/true, &error_message)) {
flac__utils_printf(stderr, 1, "%s: WARNING cuesheet \"%s\" is not audio CD compliant: %s\n", inbasefilename, cuesheet_filename, error_message);
+ if(treat_warnings_as_errors)
+ return false;
(*cuesheet)->data.cue_sheet.is_cd = false;
}
diff --git a/src/flac/encode.h b/src/flac/encode.h
index d3b7791c..183f1b5c 100644
--- a/src/flac/encode.h
+++ b/src/flac/encode.h
@@ -73,6 +73,7 @@ typedef struct {
char *requested_seek_points;
int num_requested_seek_points;
const char *cuesheet_filename;
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool continue_through_decode_errors; /* currently only obeyed when encoding from FLAC or Ogg FLAC */
FLAC__bool cued_seekpoints;
FLAC__bool channel_map_none; /* --channel-map=none specified, eventually will expand to take actual channel map */
diff --git a/src/flac/main.c b/src/flac/main.c
index 4d7c9e9e..ed3dfda7 100644
--- a/src/flac/main.c
+++ b/src/flac/main.c
@@ -99,22 +99,23 @@ static struct share__option long_options_[] = {
/*
* general options
*/
- { "help" , share__no_argument, 0, 'h' },
- { "explain" , share__no_argument, 0, 'H' },
- { "version" , share__no_argument, 0, 'v' },
- { "decode" , share__no_argument, 0, 'd' },
- { "analyze" , share__no_argument, 0, 'a' },
- { "test" , share__no_argument, 0, 't' },
- { "stdout" , share__no_argument, 0, 'c' },
- { "silent" , share__no_argument, 0, 's' },
- { "totally-silent" , share__no_argument, 0, 0 },
- { "force" , share__no_argument, 0, 'f' },
- { "delete-input-file", share__no_argument, 0, 0 },
- { "output-prefix" , share__required_argument, 0, 0 },
- { "output-name" , share__required_argument, 0, 'o' },
- { "skip" , share__required_argument, 0, 0 },
- { "until" , share__required_argument, 0, 0 },
- { "channel-map" , share__required_argument, 0, 0 }, /* undocumented */
+ { "help" , share__no_argument, 0, 'h' },
+ { "explain" , share__no_argument, 0, 'H' },
+ { "version" , share__no_argument, 0, 'v' },
+ { "decode" , share__no_argument, 0, 'd' },
+ { "analyze" , share__no_argument, 0, 'a' },
+ { "test" , share__no_argument, 0, 't' },
+ { "stdout" , share__no_argument, 0, 'c' },
+ { "silent" , share__no_argument, 0, 's' },
+ { "totally-silent" , share__no_argument, 0, 0 },
+ { "warnings-as-errors", share__no_argument, 0, 'w' },
+ { "force" , share__no_argument, 0, 'f' },
+ { "delete-input-file" , share__no_argument, 0, 0 },
+ { "output-prefix" , share__required_argument, 0, 0 },
+ { "output-name" , share__required_argument, 0, 'o' },
+ { "skip" , share__required_argument, 0, 0 },
+ { "until" , share__required_argument, 0, 0 },
+ { "channel-map" , share__required_argument, 0, 0 }, /* undocumented */
/*
* decoding options
@@ -197,6 +198,7 @@ static struct share__option long_options_[] = {
{ "no-qlp-coeff-prec-search" , share__no_argument, 0, 0 },
{ "no-padding" , share__no_argument, 0, 0 },
{ "no-verify" , share__no_argument, 0, 0 },
+ { "no-warnings-as-errors" , share__no_argument, 0, 0 },
{ "no-residual-gnuplot" , share__no_argument, 0, 0 },
{ "no-residual-text" , share__no_argument, 0, 0 },
/*
@@ -220,6 +222,7 @@ static struct {
FLAC__bool show_version;
FLAC__bool mode_decode;
FLAC__bool verify;
+ FLAC__bool treat_warnings_as_errors;
FLAC__bool force_file_overwrite;
FLAC__bool continue_through_decode_errors;
replaygain_synthesis_spec_t replaygain_synthesis_spec;
@@ -501,6 +504,7 @@ FLAC__bool init_options(void)
option_values.show_explain = false;
option_values.mode_decode = false;
option_values.verify = false;
+ option_values.treat_warnings_as_errors = false;
option_values.force_file_overwrite = false;
option_values.continue_through_decode_errors = false;
option_values.replaygain_synthesis_spec.apply = false;
@@ -562,7 +566,7 @@ int parse_options(int argc, char *argv[])
int short_option;
int option_index = 1;
FLAC__bool had_error = false;
- const char *short_opts = "0123456789aA:b:cdefFhHl:mMo:pP:q:r:sS:tT:vV";
+ const char *short_opts = "0123456789aA:b:cdefFhHl:mMo:pP:q:r:sS:tT:vVw";
while ((short_option = share__getopt_long(argc, argv, short_opts, long_options_, &option_index)) != -1) {
switch (short_option) {
@@ -812,6 +816,9 @@ int parse_option(int short_option, const char *long_option, const char *option_a
else if(0 == strcmp(long_option, "no-verify")) {
option_values.verify = false;
}
+ else if(0 == strcmp(long_option, "no-warnings-as-errors")) {
+ option_values.treat_warnings_as_errors = false;
+ }
else if(0 == strcmp(long_option, "no-residual-gnuplot")) {
option_values.aopts.do_residual_gnuplot = false;
}
@@ -887,6 +894,9 @@ int parse_option(int short_option, const char *long_option, const char *option_a
case 'V':
option_values.verify = true;
break;
+ case 'w':
+ option_values.treat_warnings_as_errors = true;
+ break;
case 'S':
FLAC__ASSERT(0 != option_argument);
if(0 == strcmp(option_argument, "-")) {
@@ -1122,6 +1132,7 @@ void show_help(void)
printf(" -c, --stdout Write output to stdout\n");
printf(" -s, --silent Do not write runtime encode/decode statistics\n");
printf(" --totally-silent Do not print anything, including errors\n");
+ printf(" -w, --warnings-as-errors Treat all warnings as errors\n");
printf(" -f, --force Force overwriting of output files\n");
printf(" -o, --output-name=FILENAME Force the output file name\n");
printf(" --output-prefix=STRING Prepend STRING to output names\n");
@@ -1196,6 +1207,7 @@ void show_help(void)
printf(" --no-silent\n");
printf(" --no-force\n");
printf(" --no-verify\n");
+ printf(" --no-warnings-as-errors\n");
}
void show_explain(void)
@@ -1234,6 +1246,7 @@ void show_explain(void)
printf(" --totally-silent Do not print anything of any kind, including\n");
printf(" warnings or errors. The exit code will be the\n");
printf(" only way to determine successful completion.\n");
+ printf(" -w, --warnings-as-errors Treat all warnings as errors\n");
printf(" -f, --force Force overwriting of output files\n");
printf(" -o, --output-name=FILENAME Force the output file name; usually flac just\n");
printf(" changes the extension. May only be used when\n");
@@ -1330,10 +1343,13 @@ void show_explain(void)
printf(" --no-cued-seekpoints is specified.\n");
printf(" --picture=SPECIFICATION Import a picture and store it in a PICTURE block.\n");
printf(" More than one --picture command can be specified.\n");
- printf(" The SPECIFICATION is a string whose parts are\n");
- printf(" separated by | characters. Some parts may be\n");
- printf(" left empty to invoke default values. The format:\n");
- printf(" [TYPE]|MIME-TYPE|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE\n");
+ printf(" The SPECIFICATION can either be a simple filename\n");
+ printf(" for the picture file, or a complete specification\n");
+ printf(" whose parts are separated by | characters. Some\n");
+ printf(" parts may be left empty to invoke default values.\n");
+ printf(" Using a filename is shorthand for \"||||FILE\".\n");
+ printf(" The SPECIFICATION format is:\n");
+ printf(" [TYPE]|[MIME-TYPE]|[DESCRIPTION]|[WIDTHxHEIGHTxDEPTH[/COLORS]]|FILE\n");
printf(" TYPE is optional; it is a number from one of:\n");
printf(" 0: Other\n");
printf(" 1: 32x32 pixels 'file icon' (PNG only)\n");
@@ -1358,10 +1374,11 @@ void show_explain(void)
printf(" 20: Publisher/Studio logotype\n");
printf(" The default is 3 (front cover). There may only be one picture each\n");
printf(" of type 1 and 2 in a file.\n");
- printf(" MIME-TYPE is mandatory; for best compatibility with players, use\n");
- printf(" pictures with MIME type image/jpeg or image/png. The MIME type can\n");
- printf(" also be --> to mean that FILE is actually a URL to an image, though\n");
- printf(" this use is discouraged.\n");
+ printf(" MIME-TYPE is optional; if left blank, it will be detected from the\n");
+ printf(" file. For best compatibility with players, use pictures with MIME\n");
+ printf(" type image/jpeg or image/png. The MIME type can also be --> to\n");
+ printf(" mean that FILE is actually a URL to an image, though this use is\n");
+ printf(" discouraged.\n");
printf(" DESCRIPTION is optional; the default is an empty string\n");
printf(" The next part specfies the resolution and color information. If\n");
printf(" the MIME-TYPE is image/jpeg, image/png, or image/gif, you can\n");
@@ -1497,6 +1514,7 @@ void show_explain(void)
printf(" --no-silent\n");
printf(" --no-force\n");
printf(" --no-verify\n");
+ printf(" --no-warnings-as-errors\n");
}
void format_mistake(const char *infilename, FileFormat wrong, FileFormat right)
@@ -1552,8 +1570,13 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
/* attempt to guess the file type based on the first 12 bytes */
if((lookahead_length = fread(lookahead, 1, 12, encode_infile)) < 12) {
- if(fmt != RAW)
+ if(fmt != RAW) {
format_mistake(infilename, fmt, RAW);
+ if(option_values.treat_warnings_as_errors) {
+ conditional_fclose(encode_infile);
+ return 1;
+ }
+ }
fmt= RAW;
}
else {
@@ -1575,8 +1598,13 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
else if(!memcmp(lookahead, "OggS", 4))
fmt= OGGFLAC;
else {
- if(fmt != RAW)
+ if(fmt != RAW) {
format_mistake(infilename, fmt, RAW);
+ if(option_values.treat_warnings_as_errors) {
+ conditional_fclose(encode_infile);
+ return 1;
+ }
+ }
fmt= RAW;
}
}
@@ -1669,6 +1697,7 @@ int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_
common_options.until_specification.is_relative = true;
common_options.verify = option_values.verify;
+ common_options.treat_warnings_as_errors = option_values.treat_warnings_as_errors;
#if FLAC__HAS_OGG
common_options.use_ogg = option_values.use_ogg;
/* set a random serial number if one has not yet been specified */
@@ -1851,6 +1880,7 @@ int decode_file(const char *infilename)
else
common_options.has_cue_specification = false;
+ common_options.treat_warnings_as_errors = option_values.treat_warnings_as_errors;
common_options.continue_through_decode_errors = option_values.continue_through_decode_errors;
common_options.replaygain_synthesis_spec = option_values.replaygain_synthesis_spec;
#if FLAC__HAS_OGG