Index: man/flac.1 =================================================================== RCS file: /cvsroot/flac/flac/man/flac.1,v retrieving revision 1.20 diff -u -r1.20 flac.1 --- man/flac.1 14 Sep 2007 15:04:49 -0000 1.20 +++ man/flac.1 15 May 2008 15:11:51 -0000 @@ -47,6 +47,9 @@ \fB-s, --silent \fR Silent mode (do not write runtime encode/decode statistics to stderr) .TP +\fB--progress-silent \fR +Progress silent mode (only write runtime encode/decode statistics to stderr at task) +.TP \fB--totally-silent \fR Do not print anything of any kind, including warnings or errors. The exit code will be the only way to determine successful completion. .TP Index: man/flac.sgml =================================================================== RCS file: /cvsroot/flac/flac/man/flac.sgml,v retrieving revision 1.72 diff -u -r1.72 flac.sgml --- man/flac.sgml 2 Oct 2007 00:11:45 -0000 1.72 +++ man/flac.sgml 15 May 2008 15:11:51 -0000 @@ -152,6 +152,14 @@ + + + + Progress silent mode (only write runtime encode/decode statistics to stderr at task completion) + + + + Index: src/flac/decode.c =================================================================== RCS file: /cvsroot/flac/flac/src/flac/decode.c,v retrieving revision 1.117 diff -u -r1.117 decode.c --- src/flac/decode.c 28 Feb 2008 05:34:25 -0000 1.117 +++ src/flac/decode.c 15 May 2008 15:11:53 -0000 @@ -332,7 +332,7 @@ } else { if(0 == (d->fout = fopen(outfilename, "wb"))) { - flac__utils_printf(stderr, 1, "%s: ERROR: can't open output file %s: %s\n", d->inbasefilename, outfilename, strerror(errno)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: can't open output file %s: %s\n", d->inbasefilename, outfilename, strerror(errno)); DecoderSession_destroy(d, /*error_occurred=*/true); return false; } @@ -365,7 +365,7 @@ if(decoder_session->foreign_metadata) { const char *error; if(!flac__foreign_metadata_read_from_flac(decoder_session->foreign_metadata, infilename, &error)) { - flac__utils_printf(stderr, 1, "%s: ERROR reading foreign metadata: %s\n", decoder_session->inbasefilename, error); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR reading foreign metadata: %s\n", decoder_session->inbasefilename, error); return false; } } @@ -374,7 +374,7 @@ decoder_session->decoder = FLAC__stream_decoder_new(); if(0 == decoder_session->decoder) { - flac__utils_printf(stderr, 1, "%s: ERROR creating the decoder instance\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR creating the decoder instance\n", decoder_session->inbasefilename); return false; } @@ -407,12 +407,12 @@ FLAC__bool DecoderSession_process(DecoderSession *d) { if(!FLAC__stream_decoder_process_until_end_of_metadata(d->decoder)) { - flac__utils_printf(stderr, 2, "\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\n"); print_error_with_state(d, "ERROR while decoding metadata"); return false; } if(FLAC__stream_decoder_get_state(d->decoder) > FLAC__STREAM_DECODER_END_OF_STREAM) { - flac__utils_printf(stderr, 2, "\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\n"); print_error_with_state(d, "ERROR during metadata decoding"); if(!d->continue_through_decode_errors) return false; @@ -468,7 +468,7 @@ } } if(!FLAC__stream_decoder_process_until_end_of_stream(d->decoder) && !d->aborting_due_to_until) { - flac__utils_printf(stderr, 2, "\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\n"); print_error_with_state(d, "ERROR while decoding data"); if(!d->continue_through_decode_errors) return false; @@ -477,7 +477,7 @@ (d->abort_flag && !(d->aborting_due_to_until || d->continue_through_decode_errors)) || (FLAC__stream_decoder_get_state(d->decoder) > FLAC__STREAM_DECODER_END_OF_STREAM && !d->aborting_due_to_until) ) { - flac__utils_printf(stderr, 2, "\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\n"); print_error_with_state(d, "ERROR during decoding"); return false; } @@ -507,19 +507,19 @@ if(d->analysis_mode) flac__analyze_finish(d->aopts); if(md5_failure) { - flac__utils_printf(stderr, 1, "\r%s: ERROR, MD5 signature mismatch\n", d->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "\r%s: ERROR, MD5 signature mismatch\n", d->inbasefilename); ok = d->continue_through_decode_errors; } 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "\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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "\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"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\r%s: %s \n", d->inbasefilename, d->test_only? "ok ":d->analysis_mode?"done ":"done"); } DecoderSession_destroy(d, /*error_occurred=*/!ok); if(!d->analysis_mode && !d->test_only && (d->is_wave_out || d->is_aiff_out)) { @@ -530,7 +530,7 @@ if(d->foreign_metadata) { const char *error; if(!flac__foreign_metadata_write_to_iff(d->foreign_metadata, d->infilename, d->outfilename, d->fm_offset1, d->fm_offset2, d->fm_offset3, &error)) { - flac__utils_printf(stderr, 1, "ERROR updating foreign metadata from %s to %s: %s\n", d->infilename, d->outfilename, error); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR updating foreign metadata from %s to %s: %s\n", d->infilename, d->outfilename, error); return 1; } } @@ -563,7 +563,7 @@ /* in any other case the total samples in the input must be known */ if(total_samples_in_input == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until when FLAC metadata has total sample count of 0\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, cannot use --until when FLAC metadata has total sample count of 0\n", inbasefilename); return false; } @@ -580,15 +580,15 @@ /* error check */ if(spec->value.samples < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before beginning of input\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, --until value is before beginning of input\n", inbasefilename); return false; } if((FLAC__uint64)spec->value.samples <= skip) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before --skip point\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, --until value is before --skip point\n", inbasefilename); return false; } if((FLAC__uint64)spec->value.samples > total_samples_in_input) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is after end of input\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, --until value is after end of input\n", inbasefilename); return false; } @@ -608,9 +608,9 @@ if(samples == 0) { if(f == stdout) { - 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"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING, don't have accurate sample count available for %s header.\n", decoder_session->inbasefilename, fmt_desc); + flac__utils_printf(stderr, VERBOSITY_SILENT, " Generated %s file will have a data chunk size of 0. Try\n", fmt_desc); + flac__utils_printf(stderr, VERBOSITY_SILENT, " decoding directly to a file instead.\n"); if(decoder_session->treat_warnings_as_errors) return false; } @@ -631,7 +631,7 @@ } if(data_size + foreign_metadata_size + 60/*worst-case*/ >= 0xFFFFFFF4) { - flac__utils_printf(stderr, 1, "%s: ERROR: stream is too big to fit in a single %s file\n", decoder_session->inbasefilename, fmt_desc); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: stream is too big to fit in a single %s file\n", decoder_session->inbasefilename, fmt_desc); return false; } @@ -651,7 +651,7 @@ /* seek forward to {allocate} or {skip over already-written chunks} before "fmt " */ for(i = 1; i < fm->format_block; i++) { if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata before \"fmt \"\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: allocating/skipping foreign metadata before \"fmt \"\n", decoder_session->inbasefilename); return false; } } @@ -666,7 +666,7 @@ /* seek forward to {allocate} or {skip over already-written chunks} after "fmt " but before "data" */ for(i = fm->format_block+1; i < fm->audio_block; i++) { if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata after \"fmt \"\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: allocating/skipping foreign metadata after \"fmt \"\n", decoder_session->inbasefilename); return false; } } @@ -698,7 +698,7 @@ /* seek forward to {allocate} or {skip over already-written chunks} before "COMM" */ for(i = 1; i < fm->format_block; i++) { if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata before \"COMM\"\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: allocating/skipping foreign metadata before \"COMM\"\n", decoder_session->inbasefilename); return false; } } @@ -713,7 +713,7 @@ /* seek forward to {allocate} or {skip over already-written chunks} after "COMM" but before "SSND" */ for(i = fm->format_block+1; i < fm->audio_block; i++) { if(fseeko(f, fm->blocks[i].size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping foreign metadata after \"COMM\"\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: allocating/skipping foreign metadata after \"COMM\"\n", decoder_session->inbasefilename); return false; } } @@ -734,7 +734,7 @@ if(ssnd_offset_size) { /* seek forward to {allocate} or {skip over already-written} SSND offset */ if(fseeko(f, ssnd_offset_size, SEEK_CUR) < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: allocating/skipping \"SSND\" offset\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: allocating/skipping \"SSND\" offset\n", decoder_session->inbasefilename); return false; } } @@ -893,7 +893,7 @@ FILE *f = fopen(d->outfilename, "r+b"); /* stream is positioned at beginning of file */ if(0 == f) { - flac__utils_printf(stderr, 1, "ERROR, couldn't open file %s while fixing up %s chunk size: %s\n", d->outfilename, fmt_desc, strerror(errno)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR, couldn't open file %s while fixing up %s chunk size: %s\n", d->outfilename, fmt_desc, strerror(errno)); return false; } @@ -933,9 +933,9 @@ if(decoder_session->bps) { if(bps != decoder_session->bps) { if(decoder_session->got_stream_info) - flac__utils_printf(stderr, 1, "%s: ERROR, bits-per-sample is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, bps, decoder_session->bps); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, bits-per-sample is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, bps, decoder_session->bps); else - flac__utils_printf(stderr, 1, "%s: ERROR, bits-per-sample is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, bps, decoder_session->bps); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, bits-per-sample is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, bps, decoder_session->bps); if(!decoder_session->continue_through_decode_errors) return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } @@ -950,9 +950,9 @@ if(decoder_session->channels) { if(channels != decoder_session->channels) { if(decoder_session->got_stream_info) - flac__utils_printf(stderr, 1, "%s: ERROR, channels is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, channels, decoder_session->channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, channels is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, channels, decoder_session->channels); else - flac__utils_printf(stderr, 1, "%s: ERROR, channels is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, channels, decoder_session->channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, channels is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, channels, decoder_session->channels); if(!decoder_session->continue_through_decode_errors) return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } @@ -967,9 +967,9 @@ if(decoder_session->sample_rate) { if(frame->header.sample_rate != decoder_session->sample_rate) { if(decoder_session->got_stream_info) - flac__utils_printf(stderr, 1, "%s: ERROR, sample rate is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, frame->header.sample_rate, decoder_session->sample_rate); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, sample rate is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, frame->header.sample_rate, decoder_session->sample_rate); else - flac__utils_printf(stderr, 1, "%s: ERROR, sample rate is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, frame->header.sample_rate, decoder_session->sample_rate); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, sample rate is %u in this frame but %u in previous frames\n", decoder_session->inbasefilename, frame->header.sample_rate, decoder_session->sample_rate); if(!decoder_session->continue_through_decode_errors) return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } @@ -989,7 +989,7 @@ if(decoder_session->skip_specification->value.samples == 0) /* special case for when no --skip was given */ decoder_session->skip_specification->is_relative = false; /* convert to our meaning of beginning-of-stream */ else { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --skip because the total sample count was not found in the metadata\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, cannot use --skip because the total sample count was not found in the metadata\n", decoder_session->inbasefilename); return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } } @@ -997,7 +997,7 @@ if(decoder_session->until_specification->value.samples == 0) /* special case for when no --until was given */ decoder_session->until_specification->is_relative = false; /* convert to our meaning of end-of-stream */ else { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until because the total sample count was not found in the metadata\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, cannot use --until because the total sample count was not found in the metadata\n", decoder_session->inbasefilename); return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; } } @@ -1219,12 +1219,12 @@ /* remember, metadata->data.stream_info.total_samples can be 0, meaning 'unknown' */ if(metadata->data.stream_info.total_samples > 0 && skip >= metadata->data.stream_info.total_samples) { - flac__utils_printf(stderr, 1, "%s: ERROR trying to --skip more samples than in stream\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR trying to --skip more samples than in stream\n", decoder_session->inbasefilename); decoder_session->abort_flag = true; return; } else if(metadata->data.stream_info.total_samples == 0 && skip > 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, can't --skip when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, can't --skip when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename); decoder_session->abort_flag = true; return; } @@ -1246,7 +1246,7 @@ } if(decoder_session->bps < 4 || decoder_session->bps > 24) { - flac__utils_printf(stderr, 1, "%s: ERROR: bits per sample is %u, must be 4-24\n", decoder_session->inbasefilename, decoder_session->bps); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: bits per sample is %u, must be 4-24\n", decoder_session->inbasefilename, decoder_session->bps); decoder_session->abort_flag = true; return; } @@ -1254,7 +1254,7 @@ else if(metadata->type == FLAC__METADATA_TYPE_CUESHEET) { /* remember, at this point, decoder_session->total_samples can be 0, meaning 'unknown' */ if(decoder_session->total_samples == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR can't use --cue when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR can't use --cue when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename); decoder_session->abort_flag = true; return; } @@ -1278,7 +1278,7 @@ if (decoder_session->replaygain.spec.apply) { 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"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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; @@ -1290,8 +1290,8 @@ decoder_session->replaygain.scale = grabbag__replaygain_compute_scale_factor(peak, gain, decoder_session->replaygain.spec.preamp, decoder_session->replaygain.spec.limiter == RGSS_LIMIT__PEAK); FLAC__ASSERT(decoder_session->bps > 0 && decoder_session->bps <= 32); 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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, VERBOSITY_SILENT, "%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 */ } } @@ -1303,7 +1303,7 @@ { DecoderSession *decoder_session = (DecoderSession*)client_data; (void)decoder; - flac__utils_printf(stderr, 1, "%s: *** Got error code %d:%s\n", decoder_session->inbasefilename, status, FLAC__StreamDecoderErrorStatusString[status]); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: *** Got error code %d:%s\n", decoder_session->inbasefilename, status, FLAC__StreamDecoderErrorStatusString[status]); if(!decoder_session->continue_through_decode_errors) { decoder_session->abort_flag = true; if(status == FLAC__STREAM_DECODER_ERROR_STATUS_UNPARSEABLE_STREAM) @@ -1315,13 +1315,13 @@ { const int ilen = strlen(d->inbasefilename) + 1; - flac__utils_printf(stderr, 1, "\n%s: %s\n", d->inbasefilename, message); + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n%s: %s\n", d->inbasefilename, message); - flac__utils_printf(stderr, 1, "%*s init status = %s\n", ilen, "", FLAC__StreamDecoderInitStatusString[init_status]); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%*s init status = %s\n", ilen, "", FLAC__StreamDecoderInitStatusString[init_status]); /* print out some more info for some errors: */ if (init_status == FLAC__STREAM_DECODER_INIT_STATUS_ERROR_OPENING_FILE) { - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n" "An error occurred opening the input file; it is likely that it does not exist\n" "or is not readable.\n" @@ -1333,12 +1333,12 @@ { const int ilen = strlen(d->inbasefilename) + 1; - flac__utils_printf(stderr, 1, "\n%s: %s\n", d->inbasefilename, message); - flac__utils_printf(stderr, 1, "%*s state = %s\n", ilen, "", FLAC__stream_decoder_get_resolved_state_string(d->decoder)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n%s: %s\n", d->inbasefilename, message); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%*s state = %s\n", ilen, "", FLAC__stream_decoder_get_resolved_state_string(d->decoder)); /* print out some more info for some errors: */ if (d->aborting_due_to_unparseable) { - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n" "The FLAC stream may have been created by a more advanced encoder. Try\n" " metaflac --show-vendor-tag %s\n" @@ -1355,7 +1355,7 @@ void print_stats(const DecoderSession *decoder_session) { - if(flac__utils_verbosity_ >= 2) { + if(flac__utils_verbosity_ > VERBOSITY_SILENT) { #if defined _MSC_VER || defined __MINGW32__ /* with MSVC you have to spoon feed it the casting */ const double progress = (double)(FLAC__int64)decoder_session->samples_processed / (double)(FLAC__int64)decoder_session->total_samples * 100.0; Index: src/flac/encode.c =================================================================== RCS file: /cvsroot/flac/flac/src/flac/encode.c,v retrieving revision 1.198 diff -u -r1.198 encode.c --- src/flac/encode.c 28 Feb 2008 05:34:25 -0000 1.198 +++ src/flac/encode.c 15 May 2008 15:11:54 -0000 @@ -206,7 +206,7 @@ while(!feof(e->fin) && !got_data_chunk) { char chunk_id[5] = { '\0', '\0', '\0', '\0', '\0' }; /* one extra byte for terminating NUL so we can also treat it like a C string */ if(!read_bytes(e->fin, (FLAC__byte*)chunk_id, 4, /*eof_ok=*/true, e->inbasefilename)) { - flac__utils_printf(stderr, 1, "%s: ERROR: incomplete chunk identifier\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: incomplete chunk identifier\n", e->inbasefilename); return false; } if(feof(e->fin)) @@ -219,7 +219,7 @@ unsigned block_align; if(got_fmt_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has multiple 'fmt ' chunks\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: file has multiple 'fmt ' chunks\n", e->inbasefilename); return false; } @@ -259,7 +259,7 @@ return false; data_bytes = xx; if(data_bytes < 16) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'fmt ' chunk has length = %u\n", e->inbasefilename, (unsigned)data_bytes); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: non-standard 'fmt ' chunk has length = %u\n", e->inbasefilename, (unsigned)data_bytes); return false; } @@ -267,7 +267,7 @@ if(!read_uint16(e->fin, /*big_endian=*/false, &wFormatTag, e->inbasefilename)) return false; if(wFormatTag != 1 /*WAVE_FORMAT_PCM*/ && wFormatTag != 65534 /*WAVE_FORMAT_EXTENSIBLE*/) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported format type %u\n", e->inbasefilename, (unsigned)wFormatTag); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unsupported format type %u\n", e->inbasefilename, (unsigned)wFormatTag); return false; } @@ -299,13 +299,13 @@ if(bps != 8 && bps != 16) { 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", e->inbasefilename, (unsigned)wFormatTag, bps); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (unsigned)wFormatTag, bps); if(e->treat_warnings_as_errors) return false; } else { /* @@@ we could add an option to specify left- or right-justified blocks so we knew how to set 'shift' */ - flac__utils_printf(stderr, 1, "%s: ERROR: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (unsigned)wFormatTag, bps); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: legacy WAVE file has format type %u but bits-per-sample=%u\n", e->inbasefilename, (unsigned)wFormatTag, bps); return false; } } @@ -313,7 +313,7 @@ if((bps+7)/8 * channels == block_align) { 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", e->inbasefilename, (unsigned)wFormatTag, block_align, bps, channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING: legacy WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (unsigned)wFormatTag, block_align, bps, channels); if(e->treat_warnings_as_errors) return false; shift = 8 - (bps % 8); @@ -323,14 +323,14 @@ shift = 0; } else { - flac__utils_printf(stderr, 1, "%s: ERROR: illegal WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (unsigned)wFormatTag, block_align, bps, channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: illegal WAVE file (format type %d) has block alignment=%u, bits-per-sample=%u, channels=%u\n", e->inbasefilename, (unsigned)wFormatTag, block_align, bps, channels); return false; } #else shift = 0; #endif if(channels > 2 && !options.channel_map_none) { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVE has >2 channels but is not WAVE_FORMAT_EXTENSIBLE; cannot assign channels\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: WAVE has >2 channels but is not WAVE_FORMAT_EXTENSIBLE; cannot assign channels\n", e->inbasefilename); return false; } FLAC__ASSERT(data_bytes >= 16); @@ -338,21 +338,21 @@ } else { if(data_bytes < 40) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with size %u\n", e->inbasefilename, (unsigned)data_bytes); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with size %u\n", e->inbasefilename, (unsigned)data_bytes); return false; } /* cbSize */ if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; if(x < 22) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with cbSize %u\n", e->inbasefilename, (unsigned)x); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with cbSize %u\n", e->inbasefilename, (unsigned)x); return false; } /* valid bps */ if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; if((unsigned)x > bps) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with wValidBitsPerSample (%u) > wBitsPerSample (%u)\n", e->inbasefilename, (unsigned)x, bps); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: invalid WAVEFORMATEXTENSIBLE chunk with wValidBitsPerSample (%u) > wBitsPerSample (%u)\n", e->inbasefilename, (unsigned)x, bps); return false; } shift = bps - (unsigned)x; @@ -418,12 +418,12 @@ } #endif else { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk with unsupported channel mask=0x%04X\n\nUse --channel-map=none option to store channels in current order; FLAC files\nmust also be decoded with --channel-map=none to restore correct order.\n", e->inbasefilename, (unsigned)channel_mask); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk with unsupported channel mask=0x%04X\n\nUse --channel-map=none option to store channels in current order; FLAC files\nmust also be decoded with --channel-map=none to restore correct order.\n", e->inbasefilename, (unsigned)channel_mask); return false; } if(!options.channel_map_none) { if(count_channel_mask_bits(channel_mask) < channels) { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has unassigned channels (#channels=%u)\n", e->inbasefilename, (unsigned)channel_mask, channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has unassigned channels (#channels=%u)\n", e->inbasefilename, (unsigned)channel_mask, channels); return false; } #if 0 @@ -435,7 +435,7 @@ channel_mask = limit_channel_mask(channel_mask, channels); #else else if(count_channel_mask_bits(channel_mask) > channels) { - flac__utils_printf(stderr, 1, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has extra bits for non-existant channels (#channels=%u)\n", e->inbasefilename, (unsigned)channel_mask, channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: WAVEFORMATEXTENSIBLE chunk: channel mask 0x%04X has extra bits for non-existant channels (#channels=%u)\n", e->inbasefilename, (unsigned)channel_mask, channels); return false; } #endif @@ -444,7 +444,7 @@ if(!read_uint16(e->fin, /*big_endian=*/false, &x, e->inbasefilename)) return false; if(x != 1) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported WAVEFORMATEXTENSIBLE chunk with non-PCM format %u\n", e->inbasefilename, (unsigned)x); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unsupported WAVEFORMATEXTENSIBLE chunk with non-PCM format %u\n", e->inbasefilename, (unsigned)x); return false; } data_bytes -= 26; @@ -454,7 +454,7 @@ /* skip any extra data in the fmt chunk */ if(!fskip_ahead(e->fin, data_bytes)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over extra 'fmt' data\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read while skipping over extra 'fmt' data\n", e->inbasefilename); return false; } @@ -464,7 +464,7 @@ FLAC__uint32 xx; if(!got_fmt_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: got 'data' chunk before 'fmt' chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: got 'data' chunk before 'fmt' chunk\n", e->inbasefilename); return false; } @@ -474,7 +474,7 @@ if(options.ignore_chunk_sizes) { FLAC__ASSERT(!options.sector_align); if(xx) { - flac__utils_printf(stderr, 1, "%s: WARNING: \"data\" chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING: \"data\" chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); if(e->treat_warnings_as_errors) return false; } @@ -483,7 +483,7 @@ else { data_bytes = xx; if(0 == data_bytes) { - flac__utils_printf(stderr, 1, "%s: ERROR: 'data' chunk has size of 0\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: 'data' chunk has size of 0\n", e->inbasefilename); return false; } } @@ -497,7 +497,7 @@ else { FLAC__uint32 xx; if(!options.format_options.iff.foreign_metadata) { - flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk '%s' (use --keep-foreign-metadata to keep)\n", e->inbasefilename, chunk_id); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING: skipping unknown chunk '%s' (use --keep-foreign-metadata to keep)\n", e->inbasefilename, chunk_id); if(e->treat_warnings_as_errors) return false; } @@ -510,7 +510,7 @@ FLAC__ASSERT(skip <= LONG_MAX); if(!fskip_ahead(e->fin, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read while skipping over chunk\n", e->inbasefilename); return false; } } @@ -518,11 +518,11 @@ } if(!got_fmt_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find fmt chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: didn't find fmt chunk\n", e->inbasefilename); return false; } if(!got_data_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find data chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: didn't find data chunk\n", e->inbasefilename); return false; } @@ -550,7 +550,7 @@ while(!feof(e->fin) && !got_ssnd_chunk) { char chunk_id[5] = { '\0', '\0', '\0', '\0', '\0' }; /* one extra byte for terminating NUL so we can also treat it like a C string */ if(!read_bytes(e->fin, (FLAC__byte*)chunk_id, 4, /*eof_ok=*/true, e->inbasefilename)) { - flac__utils_printf(stderr, 1, "%s: ERROR: incomplete chunk identifier\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: incomplete chunk identifier\n", e->inbasefilename); return false; } if(feof(e->fin)) @@ -564,7 +564,7 @@ const FLAC__uint32 minimum_comm_size = (is_aifc? 22 : 18); if(got_comm_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has multiple 'COMM' chunks\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: file has multiple 'COMM' chunks\n", e->inbasefilename); return false; } @@ -572,11 +572,11 @@ if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) return false; else if(xx < minimum_comm_size) { - flac__utils_printf(stderr, 1, "%s: ERROR: non-standard %s 'COMM' chunk has length = %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: non-standard %s 'COMM' chunk has length = %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx); return false; } 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", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx, minimum_comm_size); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING: non-standard %s 'COMM' chunk has length = %u, expected %u\n", e->inbasefilename, is_aifc? "AIFF-C" : "AIFF", (unsigned int)xx, minimum_comm_size); if(e->treat_warnings_as_errors) return false; } @@ -587,7 +587,7 @@ return false; channels = (unsigned)x; if(channels > 2 && !options.channel_map_none) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number channels %u for AIFF\n", e->inbasefilename, channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unsupported number channels %u for AIFF\n", e->inbasefilename, channels); return false; } @@ -617,7 +617,7 @@ else if(xx == 0x4E4F4E45) /* "NONE" */ ; /* nothing to do, we already default to big-endian */ else { - flac__utils_printf(stderr, 1, "%s: ERROR: can't handle AIFF-C compression type \"%c%c%c%c\"\n", e->inbasefilename, (char)(xx>>24), (char)((xx>>16)&8), (char)((xx>>8)&8), (char)(xx&8)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: can't handle AIFF-C compression type \"%c%c%c%c\"\n", e->inbasefilename, (char)(xx>>24), (char)((xx>>16)&8), (char)((xx>>8)&8), (char)(xx&8)); return false; } } @@ -647,7 +647,7 @@ /* keep default channel order */ } else { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number channels %u for AIFF\n", e->inbasefilename, channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unsupported number channels %u for AIFF\n", e->inbasefilename, channels); return false; } @@ -655,7 +655,7 @@ /* skip any extra data in the COMM chunk */ if(!fskip_ahead(e->fin, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over extra COMM data\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read while skipping over extra COMM data\n", e->inbasefilename); return false; } @@ -666,7 +666,7 @@ unsigned offset = 0, block_size = 0, data_bytes; if(!got_comm_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: got 'SSND' chunk before 'COMM' chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: got 'SSND' chunk before 'COMM' chunk\n", e->inbasefilename); return false; } @@ -676,7 +676,7 @@ if(options.ignore_chunk_sizes) { FLAC__ASSERT(!options.sector_align); if(xx) { - flac__utils_printf(stderr, 1, "%s: WARNING: \"SSND\" chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING: \"SSND\" chunk has non-zero size, using --ignore-chunk-sizes is probably a bad idea\n", e->inbasefilename, chunk_id); if(e->treat_warnings_as_errors) return false; } @@ -698,18 +698,18 @@ if(!read_uint32(e->fin, /*big_endian=*/true, &xx, e->inbasefilename)) return false; else if(xx != 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: block size is %u; must be 0\n", e->inbasefilename, (unsigned)xx); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: block size is %u; must be 0\n", e->inbasefilename, (unsigned)xx); return false; } block_size = xx; /* skip any SSND offset bytes */ if(!fskip_ahead(e->fin, offset)) { - flac__utils_printf(stderr, 1, "%s: ERROR: skipping offset in SSND chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: skipping offset in SSND chunk\n", e->inbasefilename); return false; } if(data_bytes != (sample_frames * e->info.bytes_per_wide_sample)) { - flac__utils_printf(stderr, 1, "%s: ERROR: SSND chunk size inconsistent with sample frame count\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: SSND chunk size inconsistent with sample frame count\n", e->inbasefilename); return false; } @@ -720,7 +720,7 @@ else { FLAC__uint32 xx; if(!options.format_options.iff.foreign_metadata) { - flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk '%s' (use --keep-foreign-metadata to keep)\n", e->inbasefilename, chunk_id); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING: skipping unknown chunk '%s' (use --keep-foreign-metadata to keep)\n", e->inbasefilename, chunk_id); if(e->treat_warnings_as_errors) return false; } @@ -733,7 +733,7 @@ FLAC__ASSERT(skip <= LONG_MAX); if(!fskip_ahead(e->fin, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping over chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read while skipping over chunk\n", e->inbasefilename); return false; } } @@ -741,11 +741,11 @@ } if(!got_comm_chunk) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find COMM chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: didn't find COMM chunk\n", e->inbasefilename); return false; } if(!got_ssnd_chunk && sample_frames) { - flac__utils_printf(stderr, 1, "%s: ERROR: didn't find SSND chunk\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: didn't find SSND chunk\n", e->inbasefilename); return false; } @@ -764,39 +764,39 @@ FLAC__stream_decoder_set_md5_checking(e->fmt.flac.decoder, false) && FLAC__stream_decoder_set_metadata_respond_all(e->fmt.flac.decoder) )) { - flac__utils_printf(stderr, 1, "%s: ERROR: setting up decoder for FLAC input\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: setting up decoder for FLAC input\n", e->inbasefilename); return false; } if (options.format == FORMAT_OGGFLAC) { if (FLAC__stream_decoder_init_ogg_stream(e->fmt.flac.decoder, flac_decoder_read_callback, flac_decoder_seek_callback, flac_decoder_tell_callback, flac_decoder_length_callback, flac_decoder_eof_callback, flac_decoder_write_callback, flac_decoder_metadata_callback, flac_decoder_error_callback, /*client_data=*/e) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - flac__utils_printf(stderr, 1, "%s: ERROR: initializing decoder for Ogg FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: initializing decoder for Ogg FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); return false; } } else if (FLAC__stream_decoder_init_stream(e->fmt.flac.decoder, flac_decoder_read_callback, flac_decoder_seek_callback, flac_decoder_tell_callback, flac_decoder_length_callback, flac_decoder_eof_callback, flac_decoder_write_callback, flac_decoder_metadata_callback, flac_decoder_error_callback, /*client_data=*/e) != FLAC__STREAM_DECODER_INIT_STATUS_OK) { - flac__utils_printf(stderr, 1, "%s: ERROR: initializing decoder for FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: initializing decoder for FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); return false; } if (!FLAC__stream_decoder_process_until_end_of_metadata(e->fmt.flac.decoder) || e->fmt.flac.client_data.fatal_error) { if (e->fmt.flac.client_data.fatal_error) - flac__utils_printf(stderr, 1, "%s: ERROR: out of memory or too many metadata blocks while reading metadata in FLAC input\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: out of memory or too many metadata blocks while reading metadata in FLAC input\n", e->inbasefilename); else - flac__utils_printf(stderr, 1, "%s: ERROR: reading metadata in FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: reading metadata in FLAC input, state = %s\n", e->inbasefilename, FLAC__stream_decoder_get_resolved_state_string(e->fmt.flac.decoder)); return false; } if (e->fmt.flac.client_data.num_metadata_blocks == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: reading metadata in FLAC input, got no metadata blocks\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: reading metadata in FLAC input, got no metadata blocks\n", e->inbasefilename); return false; } else if (e->fmt.flac.client_data.metadata_blocks[0]->type != FLAC__METADATA_TYPE_STREAMINFO) { - flac__utils_printf(stderr, 1, "%s: ERROR: reading metadata in FLAC input, first metadata block is not STREAMINFO\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: reading metadata in FLAC input, first metadata block is not STREAMINFO\n", e->inbasefilename); return false; } else if (e->fmt.flac.client_data.metadata_blocks[0]->data.stream_info.total_samples == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: FLAC input has STREAMINFO with unknown total samples which is not supported\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: FLAC input has STREAMINFO with unknown total samples which is not supported\n", e->inbasefilename); return false; } @@ -842,7 +842,7 @@ flac__foreign_metadata_read_from_wave(options.format_options.iff.foreign_metadata, infilename, &error) : flac__foreign_metadata_read_from_aiff(options.format_options.iff.foreign_metadata, infilename, &error) )) { - flac__utils_printf(stderr, 1, "%s: ERROR reading foreign metadata: %s\n", encoder_session.inbasefilename, error); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR reading foreign metadata: %s\n", encoder_session.inbasefilename, error); return EncoderSession_finish_error(&encoder_session); } } @@ -868,7 +868,7 @@ * set up FLAC decoder for the input */ if (0 == (encoder_session.fmt.flac.decoder = FLAC__stream_decoder_new())) { - flac__utils_printf(stderr, 1, "%s: ERROR: creating decoder for FLAC input\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: creating decoder for FLAC input\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } if(!get_sample_info_flac(&encoder_session, options)) @@ -882,28 +882,28 @@ /* some more checks */ if(encoder_session.info.channels == 0 || encoder_session.info.channels > FLAC__MAX_CHANNELS) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number of channels %u\n", encoder_session.inbasefilename, encoder_session.info.channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unsupported number of channels %u\n", encoder_session.inbasefilename, encoder_session.info.channels); return EncoderSession_finish_error(&encoder_session); } if(!FLAC__format_sample_rate_is_valid(encoder_session.info.sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported sample rate %u\n", encoder_session.inbasefilename, encoder_session.info.sample_rate); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unsupported sample rate %u\n", encoder_session.inbasefilename, encoder_session.info.sample_rate); return EncoderSession_finish_error(&encoder_session); } if(encoder_session.info.bits_per_sample-encoder_session.info.shift < 4 || encoder_session.info.bits_per_sample-encoder_session.info.shift > 24) { - flac__utils_printf(stderr, 1, "%s: ERROR: unsupported bits-per-sample %u\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unsupported bits-per-sample %u\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); return EncoderSession_finish_error(&encoder_session); } if(options.sector_align) { if(encoder_session.info.channels != 2) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.channels); return EncoderSession_finish_error(&encoder_session); } if(encoder_session.info.sample_rate != 44100) { - flac__utils_printf(stderr, 1, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.sample_rate); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.sample_rate); return EncoderSession_finish_error(&encoder_session); } if(encoder_session.info.bits_per_sample-encoder_session.info.shift != 16) { - flac__utils_printf(stderr, 1, "%s: ERROR: file has %u bits-per-sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: file has %u bits-per-sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, encoder_session.info.bits_per_sample-encoder_session.info.shift); return EncoderSession_finish_error(&encoder_session); } } @@ -968,7 +968,7 @@ encoder_session.fmt.iff.data_bytes -= (unsigned)skip * encoder_session.info.bytes_per_wide_sample; /*@@@ WATCHOUT: 4GB limit */ if(options.ignore_chunk_sizes) { encoder_session.total_samples_to_encode = 0; - flac__utils_printf(stderr, 2, "(No runtime statistics possible; please wait for encoding to finish...)\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "(No runtime statistics possible; please wait for encoding to finish...)\n"); FLAC__ASSERT(0 == until); } else { @@ -1034,7 +1034,7 @@ } if(encoder_session.total_samples_to_encode == 0) - flac__utils_printf(stderr, 2, "(No runtime statistics possible; please wait for encoding to finish...)\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "(No runtime statistics possible; please wait for encoding to finish...)\n"); if(options.format == FORMAT_FLAC || options.format == FORMAT_OGGFLAC) encoder_session.fmt.flac.client_data.samples_left_to_process = encoder_session.total_samples_to_encode; @@ -1053,7 +1053,7 @@ skip_bytes -= lookahead_length; lookahead_length = 0; if(!fskip_ahead(encoder_session.fin, skip_bytes)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } } @@ -1067,7 +1067,7 @@ case FORMAT_AIFF: case FORMAT_AIFF_C: if(!fskip_ahead(encoder_session.fin, skip * encoder_session.info.bytes_per_wide_sample)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } break; @@ -1081,7 +1081,7 @@ * encoder */ if(!FLAC__stream_decoder_seek_absolute(encoder_session.fmt.flac.decoder, skip)) { - flac__utils_printf(stderr, 1, "%s: ERROR while skipping samples, FLAC decoder state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR while skipping samples, FLAC decoder state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); return EncoderSession_finish_error(&encoder_session); } break; @@ -1135,7 +1135,7 @@ memcpy(ucbuffer_, lookahead, lookahead_length); bytes_read = fread(ucbuffer_+lookahead_length, sizeof(unsigned char), CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample - lookahead_length, infile) + lookahead_length; if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } lookahead_length = 0; @@ -1145,12 +1145,12 @@ if(bytes_read == 0) { if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } } else if(bytes_read % encoder_session.info.bytes_per_wide_sample != 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } else { @@ -1182,7 +1182,7 @@ if(wanted > 0) { bytes_read += fread(ucbuffer_+lookahead_length, sizeof(unsigned char), wanted, infile); if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } } @@ -1194,11 +1194,11 @@ if(bytes_read == 0) { if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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; @@ -1206,7 +1206,7 @@ } else { if(bytes_read % encoder_session.info.bytes_per_wide_sample != 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } else { @@ -1231,15 +1231,15 @@ size_t bytes_read = fread(ucbuffer_, sizeof(unsigned char), min(encoder_session.fmt.iff.data_bytes, CHUNK_OF_SAMPLES * encoder_session.info.bytes_per_wide_sample), infile); if(bytes_read == 0) { if(ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } else if(feof(infile)) { if(options.ignore_chunk_sizes) { - flac__utils_printf(stderr, 1, "%s: INFO: hit EOF with --ignore-chunk-sizes, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.samples_written); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: INFO: hit EOF with --ignore-chunk-sizes, got %u samples\n", encoder_session.inbasefilename, (unsigned)encoder_session.samples_written); } else { - 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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); } @@ -1248,7 +1248,7 @@ } else { if(bytes_read % encoder_session.info.bytes_per_wide_sample != 0) { - flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } else { @@ -1275,12 +1275,12 @@ if(encoder_session.continue_through_decode_errors && FLAC__stream_decoder_get_state(encoder_session.fmt.flac.decoder) == FLAC__STREAM_DECODER_END_OF_STREAM) break; if(!FLAC__stream_decoder_process_single(encoder_session.fmt.flac.decoder)) { - flac__utils_printf(stderr, 1, "%s: ERROR: while decoding FLAC input, state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: while decoding FLAC input, state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); return EncoderSession_finish_error(&encoder_session); } } if(encoder_session.fmt.flac.client_data.fatal_error) { - flac__utils_printf(stderr, 1, "%s: ERROR: while decoding FLAC input, state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: while decoding FLAC input, state = %s\n", encoder_session.inbasefilename, FLAC__stream_decoder_get_resolved_state_string(encoder_session.fmt.flac.decoder)); return EncoderSession_finish_error(&encoder_session); } break; @@ -1315,11 +1315,11 @@ FLAC__ASSERT(CHUNK_OF_SAMPLES >= 588); bytes_read = fread(ucbuffer_, sizeof(unsigned char), (*options.align_reservoir_samples) * encoder_session.info.bytes_per_wide_sample, infile); if(bytes_read == 0 && ferror(infile)) { - flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR during read\n", encoder_session.inbasefilename); return EncoderSession_finish_error(&encoder_session); } else if(bytes_read != (*options.align_reservoir_samples) * encoder_session.info.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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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); } @@ -1415,13 +1415,13 @@ e->seek_table_template = 0; if(0 == (e->seek_table_template = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE))) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for seek table\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR allocating memory for seek table\n", e->inbasefilename); return false; } e->encoder = FLAC__stream_encoder_new(); if(0 == e->encoder) { - flac__utils_printf(stderr, 1, "%s: ERROR creating the encoder instance\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR creating the encoder instance\n", e->inbasefilename); EncoderSession_destroy(e); return false; } @@ -1474,7 +1474,7 @@ print_error_with_state(e, "ERROR during encoding"); else if(e->total_samples_to_encode > 0) { print_stats(e); - flac__utils_printf(stderr, 2, "\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\n"); } if(verify_error) { @@ -1483,10 +1483,10 @@ } else { if(info_align_carry >= 0) { - flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d samples to be carried over\n", e->inbasefilename, info_align_carry); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: INFO: sector alignment causing %d samples to be carried over\n", e->inbasefilename, info_align_carry); } if(info_align_zero >= 0) { - flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d zero samples to be appended\n", e->inbasefilename, info_align_zero); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: INFO: sector alignment causing %d zero samples to be appended\n", e->inbasefilename, info_align_zero); } } @@ -1494,7 +1494,7 @@ if(ret == 0 && foreign_metadata) { const char *error; if(!flac__foreign_metadata_write_to_flac(foreign_metadata, e->infilename, e->outfilename, &error)) { - flac__utils_printf(stderr, 1, "%s: ERROR: updating foreign metadata in FLAC file: %s\n", e->inbasefilename, error); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: updating foreign metadata in FLAC file: %s\n", e->inbasefilename, error); ret = 1; } } @@ -1509,7 +1509,7 @@ FLAC__ASSERT(e->encoder); if(e->total_samples_to_encode > 0) - flac__utils_printf(stderr, 2, "\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\n"); if(FLAC__stream_encoder_get_state(e->encoder) == FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA) print_verify_error(e); @@ -1591,16 +1591,16 @@ if(e->replay_gain) { if(channels != 1 && channels != 2) { - flac__utils_printf(stderr, 1, "%s: ERROR, number of channels (%u) must be 1 or 2 for --replay-gain\n", e->inbasefilename, channels); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, number of channels (%u) must be 1 or 2 for --replay-gain\n", e->inbasefilename, channels); return false; } if(!grabbag__replaygain_is_valid_sample_frequency(sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR, invalid sample rate (%u) for --replay-gain\n", e->inbasefilename, sample_rate); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, invalid sample rate (%u) for --replay-gain\n", e->inbasefilename, sample_rate); return false; } if(options.is_first_file) { if(!grabbag__replaygain_init(sample_rate)) { - flac__utils_printf(stderr, 1, "%s: ERROR initializing ReplayGain stage\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR initializing ReplayGain stage\n", e->inbasefilename); return false; } } @@ -1610,7 +1610,7 @@ return false; if(!convert_to_seek_table_template(options.requested_seek_points, options.num_requested_seek_points, options.cued_seekpoints? static_metadata.cuesheet : 0, e)) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for seek table\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR allocating memory for seek table\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1629,7 +1629,7 @@ for(i = 0; i < options.num_pictures; i++) { FLAC__StreamMetadata *pic = FLAC__metadata_object_clone(options.pictures[i]); if(0 == pic) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for PICTURE block\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR allocating memory for PICTURE block\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1652,7 +1652,7 @@ vc_found = true; 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], &e->info.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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING, replacing tags from input FLAC file with those given on the command-line\n", e->inbasefilename); if(e->treat_warnings_as_errors) { static_metadata_clear(&static_metadata); return false; @@ -1668,7 +1668,7 @@ /* prepend ours */ FLAC__StreamMetadata *vc = FLAC__metadata_object_clone(options.vorbis_comment); if(0 == vc || (e->info.channel_mask && !flac__utils_set_channel_mask_tag(vc, e->info.channel_mask))) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for VORBIS_COMMENT block\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR allocating memory for VORBIS_COMMENT block\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1691,7 +1691,7 @@ if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_CUESHEET && 0 == static_metadata.cuesheet) { 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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) { static_metadata_clear(&static_metadata); return false; @@ -1699,7 +1699,7 @@ 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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) { static_metadata_clear(&static_metadata); return false; @@ -1709,7 +1709,7 @@ } if(flac_decoder_data->metadata_blocks[i]->type == FLAC__METADATA_TYPE_CUESHEET && (existing_cuesheet_is_bad || 0 != static_metadata.cuesheet)) { if(0 != static_metadata.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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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) { static_metadata_clear(&static_metadata); return false; @@ -1726,7 +1726,7 @@ /* prepend ours */ FLAC__StreamMetadata *cs = FLAC__metadata_object_clone(static_metadata.cuesheet); if(0 == cs) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for CUESHEET block\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR allocating memory for CUESHEET block\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1756,7 +1756,7 @@ 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) { - flac__utils_printf(stderr, 1, "%s: WARNING, replacing seektable in input FLAC file with the one given on the command-line\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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) { static_metadata_clear(&static_metadata); return false; @@ -1765,7 +1765,7 @@ else if(options.num_requested_seek_points == 0) ; /* no warning, silently delete existing SEEKTABLE since user specified --no-seektable (-S-) */ 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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) { static_metadata_clear(&static_metadata); return false; @@ -1783,7 +1783,7 @@ /* prepend ours */ FLAC__StreamMetadata *st = FLAC__metadata_object_clone(e->seek_table_template); if(0 == st) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for SEEKTABLE block\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR allocating memory for SEEKTABLE block\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1824,7 +1824,7 @@ if(p > 0 && flac_decoder_data->num_metadata_blocks < sizeof(flac_decoder_data->metadata_blocks)/sizeof(flac_decoder_data->metadata_blocks[0])) { flac_decoder_data->metadata_blocks[flac_decoder_data->num_metadata_blocks] = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); if(0 == flac_decoder_data->metadata_blocks[flac_decoder_data->num_metadata_blocks]) { - flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for PADDING block\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR allocating memory for PADDING block\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1852,7 +1852,7 @@ static_metadata_append(&static_metadata, static_metadata.cuesheet, /*needs_delete=*/false); if(e->info.channel_mask) { if(!flac__utils_set_channel_mask_tag(options.vorbis_comment, e->info.channel_mask)) { - flac__utils_printf(stderr, 1, "%s: ERROR adding channel mask tag\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR adding channel mask tag\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1864,7 +1864,7 @@ for(i = 0; i < foreign_metadata->num_blocks; i++) { FLAC__StreamMetadata *p = FLAC__metadata_object_new(FLAC__METADATA_TYPE_PADDING); if(!p) { - flac__utils_printf(stderr, 1, "%s: ERROR: out of memory\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: out of memory\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1915,7 +1915,7 @@ break; case CST_APODIZATION: if(strlen(apodizations)+strlen(options.compression_settings[i].value.t_string)+2 >= sizeof(apodizations)) { - flac__utils_printf(stderr, 1, "%s: ERROR: too many apodization functions requested\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: too many apodization functions requested\n", e->inbasefilename); static_metadata_clear(&static_metadata); return false; } @@ -1959,7 +1959,7 @@ FLAC__stream_encoder_disable_fixed_subframes(e->encoder, options.debug.disable_fixed_subframes); FLAC__stream_encoder_disable_verbatim_subframes(e->encoder, options.debug.disable_verbatim_subframes); if(!options.debug.do_md5) { - flac__utils_printf(stderr, 1, "%s: WARNING, MD5 computation disabled, resulting file will not have MD5 sum\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING, MD5 computation disabled, resulting file will not have MD5 sum\n", e->inbasefilename); if(e->treat_warnings_as_errors) { static_metadata_clear(&static_metadata); return false; @@ -2003,7 +2003,7 @@ { if(e->replay_gain) { if(!grabbag__replaygain_analyze(buffer, e->info.channels==2, e->info.bits_per_sample, samples)) { - flac__utils_printf(stderr, 1, "%s: WARNING, error while calculating ReplayGain\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING, error while calculating ReplayGain\n", e->inbasefilename); if(e->treat_warnings_as_errors) return false; } @@ -2054,7 +2054,7 @@ 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: WARNING, cannot write back seekpoints when encoding to stdout\n", e->inbasefilename); if(e->treat_warnings_as_errors) return false; } @@ -2076,7 +2076,7 @@ /* in any other case the total samples in the input must be known */ if(total_samples_in_input == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until when input length is unknown\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, cannot use --until when input length is unknown\n", inbasefilename); return false; } @@ -2093,15 +2093,15 @@ /* error check */ if(spec->value.samples < 0) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before beginning of input\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, --until value is before beginning of input\n", inbasefilename); return false; } if((FLAC__uint64)spec->value.samples <= skip) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before --skip point\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, --until value is before --skip point\n", inbasefilename); return false; } if((FLAC__uint64)spec->value.samples > total_samples_in_input) { - flac__utils_printf(stderr, 1, "%s: ERROR, --until value is after end of input\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR, --until value is after end of input\n", inbasefilename); return false; } @@ -2119,32 +2119,32 @@ const FLAC__StreamMetadata *m = metadata[i]; if(m->type == FLAC__METADATA_TYPE_SEEKTABLE) { if(!FLAC__format_seektable_is_legal(&m->data.seek_table)) { - flac__utils_printf(stderr, 1, "%s: ERROR: SEEKTABLE metadata block is invalid\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: SEEKTABLE metadata block is invalid\n", e->inbasefilename); return false; } } else if(m->type == FLAC__METADATA_TYPE_CUESHEET) { if(!FLAC__format_cuesheet_is_legal(&m->data.cue_sheet, m->data.cue_sheet.is_cd, /*violation=*/0)) { - flac__utils_printf(stderr, 1, "%s: ERROR: CUESHEET metadata block is invalid\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: CUESHEET metadata block is invalid\n", e->inbasefilename); return false; } } else if(m->type == FLAC__METADATA_TYPE_PICTURE) { const char *error = 0; if(!FLAC__format_picture_is_legal(&m->data.picture, &error)) { - flac__utils_printf(stderr, 1, "%s: ERROR: PICTURE metadata block is invalid: %s\n", e->inbasefilename, error); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: PICTURE metadata block is invalid: %s\n", e->inbasefilename, error); return false; } if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD) { if(metadata_picture_has_type1) { - flac__utils_printf(stderr, 1, "%s: ERROR: there may only be one picture of type 1 (32x32 icon) in the file\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: there may only be one picture of type 1 (32x32 icon) in the file\n", e->inbasefilename); return false; } metadata_picture_has_type1 = true; } else if(m->data.picture.type == FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON) { if(metadata_picture_has_type2) { - flac__utils_printf(stderr, 1, "%s: ERROR: there may only be one picture of type 2 (icon) in the file\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: there may only be one picture of type 2 (icon) in the file\n", e->inbasefilename); return false; } metadata_picture_has_type2 = true; @@ -2238,7 +2238,7 @@ for(wide_sample = 0; wide_sample < wide_samples; wide_sample++) for(channel = 0; channel < channels; channel++) { if(out[channel][wide_sample] & mask) { - flac__utils_printf(stderr, 1, "ERROR during read, sample data (channel#%u sample#%u = %d) has non-zero least-significant bits\n WAVE/AIFF header said the last %u bits are not significant and should be zero.\n", channel, wide_sample, out[channel][wide_sample], shift); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR during read, sample data (channel#%u sample#%u = %d) has non-zero least-significant bits\n WAVE/AIFF header said the last %u bits are not significant and should be zero.\n", channel, wide_sample, out[channel][wide_sample], shift); return false; } out[channel][wide_sample] >>= shift; @@ -2382,7 +2382,7 @@ FLACDecoderData *data = &e->fmt.flac.client_data; (void)decoder; - flac__utils_printf(stderr, 1, "%s: ERROR got %s while decoding FLAC input\n", e->inbasefilename, FLAC__StreamDecoderErrorStatusString[status]); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR got %s while decoding FLAC input\n", e->inbasefilename, FLAC__StreamDecoderErrorStatusString[status]); if(!e->continue_through_decode_errors) data->fatal_error = true; } @@ -2397,12 +2397,12 @@ return true; if(lead_out_offset == 0) { - flac__utils_printf(stderr, 1, "%s: ERROR cannot import cuesheet when the number of input samples to encode is unknown\n", inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR cannot import cuesheet when the number of input samples to encode is unknown\n", inbasefilename); return false; } if(0 == (f = fopen(cuesheet_filename, "r"))) { - flac__utils_printf(stderr, 1, "%s: ERROR opening cuesheet \"%s\" for reading: %s\n", inbasefilename, cuesheet_filename, strerror(errno)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR opening cuesheet \"%s\" for reading: %s\n", inbasefilename, cuesheet_filename, strerror(errno)); return false; } @@ -2411,18 +2411,18 @@ fclose(f); if(0 == *cuesheet) { - flac__utils_printf(stderr, 1, "%s: ERROR parsing cuesheet \"%s\" on line %u: %s\n", inbasefilename, cuesheet_filename, last_line_read, error_message); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR parsing cuesheet \"%s\" on line %u: %s\n", inbasefilename, cuesheet_filename, last_line_read, error_message); return false; } if(!FLAC__format_cuesheet_is_legal(&(*cuesheet)->data.cue_sheet, /*check_cd_da_subset=*/false, &error_message)) { - flac__utils_printf(stderr, 1, "%s: ERROR parsing cuesheet \"%s\": %s\n", inbasefilename, cuesheet_filename, error_message); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR parsing cuesheet \"%s\": %s\n", inbasefilename, cuesheet_filename, error_message); return false; } /* 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); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%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; @@ -2444,22 +2444,25 @@ const double ratio = (double)encoder_session->bytes_written / ((double)(uesize? uesize:1) * min(1.0, progress)); #endif + int verbosity = VERBOSITY_PROGRESS_SILENT; + FLAC__ASSERT(encoder_session->total_samples_to_encode > 0); if(samples_written == encoder_session->total_samples_to_encode) { - flac__utils_printf(stderr, 2, "\r%s:%s wrote %u bytes, ratio=", + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\r%s:%s wrote %u bytes, ratio=", encoder_session->inbasefilename, encoder_session->verify? " Verify OK," : "", (unsigned)encoder_session->bytes_written ); } else { - flac__utils_printf(stderr, 2, "\r%s: %u%% complete, ratio=", encoder_session->inbasefilename, (unsigned)floor(progress * 100.0 + 0.5)); + flac__utils_printf(stderr, VERBOSITY_NO_SILENT, "\r%s: %u%% complete, ratio=", encoder_session->inbasefilename, (unsigned)floor(progress * 100.0 + 0.5)); + verbosity = VERBOSITY_NO_SILENT; } if(uesize) - flac__utils_printf(stderr, 2, "%0.3f", ratio); + flac__utils_printf(stderr, verbosity, "%0.3f", ratio); else - flac__utils_printf(stderr, 2, "N/A"); + flac__utils_printf(stderr, verbosity, "N/A"); } void print_error_with_init_status(const EncoderSession *e, const char *message, FLAC__StreamEncoderInitStatus init_status) @@ -2467,24 +2470,24 @@ const int ilen = strlen(e->inbasefilename) + 1; const char *state_string = ""; - flac__utils_printf(stderr, 1, "\n%s: %s\n", e->inbasefilename, message); + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n%s: %s\n", e->inbasefilename, message); - flac__utils_printf(stderr, 1, "%*s init_status = %s\n", ilen, "", FLAC__StreamEncoderInitStatusString[init_status]); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%*s init_status = %s\n", ilen, "", FLAC__StreamEncoderInitStatusString[init_status]); if(init_status == FLAC__STREAM_ENCODER_INIT_STATUS_ENCODER_ERROR) { state_string = FLAC__stream_encoder_get_resolved_state_string(e->encoder); - flac__utils_printf(stderr, 1, "%*s state = %s\n", ilen, "", state_string); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%*s state = %s\n", ilen, "", state_string); /* print out some more info for some errors: */ if(0 == strcmp(state_string, FLAC__StreamEncoderStateString[FLAC__STREAM_ENCODER_CLIENT_ERROR])) { - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n" "An error occurred while writing; the most common cause is that the disk is full.\n" ); } else if(0 == strcmp(state_string, FLAC__StreamEncoderStateString[FLAC__STREAM_ENCODER_IO_ERROR])) { - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n" "An error occurred opening the output file; it is likely that the output\n" "directory does not exist or is not writable, the output file already exists and\n" @@ -2493,7 +2496,7 @@ } } else if(init_status == FLAC__STREAM_ENCODER_INIT_STATUS_NOT_STREAMABLE) { - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n" "The encoding parameters specified do not conform to the FLAC Subset and may not\n" "be streamable or playable in hardware devices. If you really understand the\n" @@ -2508,15 +2511,15 @@ const int ilen = strlen(e->inbasefilename) + 1; const char *state_string; - flac__utils_printf(stderr, 1, "\n%s: %s\n", e->inbasefilename, message); + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n%s: %s\n", e->inbasefilename, message); state_string = FLAC__stream_encoder_get_resolved_state_string(e->encoder); - flac__utils_printf(stderr, 1, "%*s state = %s\n", ilen, "", state_string); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%*s state = %s\n", ilen, "", state_string); /* print out some more info for some errors: */ if(0 == strcmp(state_string, FLAC__StreamEncoderStateString[FLAC__STREAM_ENCODER_CLIENT_ERROR])) { - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "\n" "An error occurred while writing; the most common cause is that the disk is full.\n" ); @@ -2534,20 +2537,20 @@ FLAC__stream_encoder_get_verify_decoder_error_stats(e->encoder, &absolute_sample, &frame_number, &channel, &sample, &expected, &got); - flac__utils_printf(stderr, 1, "%s: ERROR: mismatch in decoded data, verify FAILED!\n", e->inbasefilename); - flac__utils_printf(stderr, 1, " Absolute sample=%u, frame=%u, channel=%u, sample=%u, expected %d, got %d\n", (unsigned)absolute_sample, frame_number, channel, sample, expected, got); - flac__utils_printf(stderr, 1, " In all known cases, verify errors are caused by hardware problems,\n"); - flac__utils_printf(stderr, 1, " usually overclocking or bad RAM. Delete %s\n", e->outfilename); - flac__utils_printf(stderr, 1, " and repeat the flac command exactly as before. If it does not give a\n"); - flac__utils_printf(stderr, 1, " verify error in the exact same place each time you try it, then there is\n"); - flac__utils_printf(stderr, 1, " a problem with your hardware; please see the FAQ:\n"); - flac__utils_printf(stderr, 1, " http://flac.sourceforge.net/faq.html#tools__hardware_prob\n"); - flac__utils_printf(stderr, 1, " If it does fail in the exact same place every time, keep\n"); - flac__utils_printf(stderr, 1, " %s and submit a bug report to:\n", e->outfilename); - flac__utils_printf(stderr, 1, " https://sourceforge.net/bugs/?func=addbug&group_id=13478\n"); - flac__utils_printf(stderr, 1, " Make sure to upload the FLAC file and use the \"Monitor\" feature to\n"); - flac__utils_printf(stderr, 1, " monitor the bug status.\n"); - flac__utils_printf(stderr, 1, "Verify FAILED! Do not trust %s\n", e->outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: mismatch in decoded data, verify FAILED!\n", e->inbasefilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, " Absolute sample=%u, frame=%u, channel=%u, sample=%u, expected %d, got %d\n", (unsigned)absolute_sample, frame_number, channel, sample, expected, got); + flac__utils_printf(stderr, VERBOSITY_SILENT, " In all known cases, verify errors are caused by hardware problems,\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " usually overclocking or bad RAM. Delete %s\n", e->outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, " and repeat the flac command exactly as before. If it does not give a\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " verify error in the exact same place each time you try it, then there is\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " a problem with your hardware; please see the FAQ:\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " http://flac.sourceforge.net/faq.html#tools__hardware_prob\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " If it does fail in the exact same place every time, keep\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " %s and submit a bug report to:\n", e->outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, " https://sourceforge.net/bugs/?func=addbug&group_id=13478\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " Make sure to upload the FLAC file and use the \"Monitor\" feature to\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " monitor the bug status.\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "Verify FAILED! Do not trust %s\n", e->outfilename); } FLAC__bool read_bytes(FILE *f, FLAC__byte *buf, size_t n, FLAC__bool eof_ok, const char *fn) @@ -2556,14 +2559,14 @@ if(bytes_read == 0) { if(!eof_ok) { - flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unexpected EOF\n", fn); return false; } else return true; } if(bytes_read < n) { - flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: unexpected EOF\n", fn); return false; } return true; @@ -2611,7 +2614,7 @@ e = ((FLAC__uint16)(buf[0])<<8 | (FLAC__uint16)(buf[1]))-0x3FFF; shift = 63-e; if((buf[0]>>7)==1U || e<0 || e>63) { - flac__utils_printf(stderr, 1, "%s: ERROR: invalid floating-point value\n", fn); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR: invalid floating-point value\n", fn); return false; } Index: src/flac/main.c =================================================================== RCS file: /cvsroot/flac/flac/src/flac/main.c,v retrieving revision 1.174 diff -u -r1.174 main.c --- src/flac/main.c 28 Feb 2008 05:34:26 -0000 1.174 +++ src/flac/main.c 15 May 2008 15:11:55 -0000 @@ -106,6 +106,7 @@ { "test" , share__no_argument, 0, 't' }, { "stdout" , share__no_argument, 0, 'c' }, { "silent" , share__no_argument, 0, 's' }, + { "progress-silent" , share__no_argument, 0, 0 }, { "totally-silent" , share__no_argument, 0, 0 }, { "warnings-as-errors" , share__no_argument, 0, 'w' }, { "force" , share__no_argument, 0, 'f' }, @@ -307,7 +308,7 @@ srand((unsigned)time(0)); setlocale(LC_ALL, ""); if(!init_options()) { - flac__utils_printf(stderr, 1, "ERROR: allocating memory\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: allocating memory\n"); retval = 1; } else { @@ -338,7 +339,7 @@ } else { if(option_values.num_files == 0) { - if(flac__utils_verbosity_ >= 1) + if(flac__utils_verbosity_ >= VERBOSITY_SILENT) short_usage(); return 0; } @@ -441,7 +442,7 @@ (option_values.padding >= 0 && option_values.padding < (int)GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED) || (option_values.padding < 0 && FLAC_ENCODE__DEFAULT_PADDING < (int)GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED) ) { - flac__utils_printf(stderr, 1, "NOTE: --replay-gain may leave a small PADDING block even with --no-padding\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "NOTE: --replay-gain may leave a small PADDING block even with --no-padding\n"); option_values.padding = GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED; } else { @@ -468,14 +469,14 @@ /*@@@@@@*/ if(option_values.delete_input) return usage_error("ERROR: using --delete-input-file with --keep-foreign-metadata has been disabled until more testing has been done.\n"); - flac__utils_printf(stderr, 1, "NOTE: --keep-foreign-metadata is a new feature; make sure to test the output file before deleting the original.\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "NOTE: --keep-foreign-metadata is a new feature; make sure to test the output file before deleting the original.\n"); } } - flac__utils_printf(stderr, 2, "\n"); - flac__utils_printf(stderr, 2, "flac %s, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008 Josh Coalson\n", FLAC__VERSION_STRING); - flac__utils_printf(stderr, 2, "flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n"); - flac__utils_printf(stderr, 2, "welcome to redistribute it under certain conditions. Type `flac' for details.\n\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "flac %s, Copyright (C) 2000,2001,2002,2003,2004,2005,2006,2007,2008 Josh Coalson\n", FLAC__VERSION_STRING); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n"); + flac__utils_printf(stderr, VERBOSITY_PROGRESS_SILENT, "welcome to redistribute it under certain conditions. Type `flac' for details.\n\n"); if(option_values.mode_decode) { FLAC__bool first = true; @@ -499,7 +500,7 @@ FLAC__bool first = true; if(option_values.ignore_chunk_sizes) - flac__utils_printf(stderr, 1, "INFO: Make sure you know what you're doing when using --ignore-chunk-sizes.\n Improper use can cause flac to encode non-audio data as audio.\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "INFO: Make sure you know what you're doing when using --ignore-chunk-sizes.\n Improper use can cause flac to encode non-audio data as audio.\n"); if(option_values.num_files == 0) { retval = encode_file("-", first, true); @@ -520,17 +521,17 @@ for(i = 0; i < option_values.num_files; i++) { const char *error, *outfilename = get_encoded_outfilename(option_values.filenames[i]); if(0 == outfilename) { - flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", option_values.filenames[i]); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: filename too long: %s", option_values.filenames[i]); return 1; } if(0 == strcmp(option_values.filenames[i], "-")) { FLAC__ASSERT(0); /* double protection */ - flac__utils_printf(stderr, 1, "internal error\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "internal error\n"); return 2; } if(0 != (error = grabbag__replaygain_store_to_file_album(outfilename, album_gain, album_peak, option_values.preserve_modtime))) { - flac__utils_printf(stderr, 1, "%s: ERROR writing ReplayGain album tags (%s)\n", outfilename, error); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR writing ReplayGain album tags (%s)\n", outfilename, error); retval = 1; } } @@ -659,7 +660,10 @@ if(short_option == 0) { FLAC__ASSERT(0 != long_option); if(0 == strcmp(long_option, "totally-silent")) { - flac__utils_verbosity_ = 0; + flac__utils_verbosity_ = VERBOSITY_TOTALLY_SILENT; + } + if(0 == strcmp(long_option, "progress-silent")) { + flac__utils_verbosity_ = VERBOSITY_PROGRESS_SILENT; } else if(0 == strcmp(long_option, "delete-input-file")) { option_values.delete_input = true; @@ -773,8 +777,8 @@ option_values.ignore_chunk_sizes = true; } else if(0 == strcmp(long_option, "sector-align")) { - flac__utils_printf(stderr, 1, "WARNING: --sector-align is DEPRECATED and may not exist in future versions of flac.\n"); - flac__utils_printf(stderr, 1, " shntool provides similar functionality\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "WARNING: --sector-align is DEPRECATED and may not exist in future versions of flac.\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, " shntool provides similar functionality\n"); option_values.sector_align = true; } #if FLAC__HAS_OGG @@ -832,7 +836,7 @@ option_values.continue_through_decode_errors = false; } else if(0 == strcmp(long_option, "no-silent")) { - flac__utils_verbosity_ = 2; + flac__utils_verbosity_ = VERBOSITY_NO_SILENT; } else if(0 == strcmp(long_option, "no-force")) { option_values.force_file_overwrite = false; @@ -935,7 +939,7 @@ option_values.force_to_stdout = true; break; case 's': - flac__utils_verbosity_ = 1; + flac__utils_verbosity_ = VERBOSITY_SILENT; break; case 'f': option_values.force_file_overwrite = true; @@ -1118,7 +1122,7 @@ int usage_error(const char *message, ...) { - if(flac__utils_verbosity_ >= 1) { + if(flac__utils_verbosity_ >= VERBOSITY_SILENT) { va_list args; FLAC__ASSERT(0 != message); @@ -1211,6 +1215,7 @@ printf(" -a, --analyze Same as -d except an analysis file is written\n"); printf(" -c, --stdout Write output to stdout\n"); printf(" -s, --silent Do not write runtime encode/decode statistics\n"); + printf(" --progress-silent Only write runtime encode/decode statistics at task completion\n"); printf(" --totally-silent Do not print anything, including errors\n"); printf(" --no-utf8-convert Do not convert tags from local charset to UTF-8\n"); printf(" -w, --warnings-as-errors Treat all warnings as errors\n"); @@ -1334,6 +1339,7 @@ printf(" -a, --analyze Same as -d except an analysis file is written\n"); printf(" -c, --stdout Write output to stdout\n"); printf(" -s, --silent Do not write runtime encode/decode statistics\n"); + printf(" --progress-silent Only write runtime encode/decode statistics at task completion\n"); 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"); @@ -1640,7 +1646,7 @@ { /* WATCHOUT: indexed by FileFormat */ static const char * const ff[] = { " raw", " WAVE", "n AIFF", "n AIFF-C", " FLAC", "n Ogg FLAC" }; - flac__utils_printf(stderr, 1, "WARNING: %s is not a%s file; treating as a%s file\n", infilename, ff[wrong], ff[right]); + flac__utils_printf(stderr, VERBOSITY_SILENT, "WARNING: %s is not a%s file; treating as a%s file\n", infilename, ff[wrong], ff[right]); } int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_last_file) @@ -1657,7 +1663,7 @@ char *internal_outfilename = 0; /* NULL implies 'use outfilename' */ if(0 == outfilename) { - flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", infilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: filename too long: %s", infilename); return 1; } @@ -1668,7 +1674,7 @@ else { infilesize = grabbag__file_get_filesize(infilename); if(0 == (encode_infile = fopen(infilename, "rb"))) { - flac__utils_printf(stderr, 1, "ERROR: can't open input file %s: %s\n", infilename, strerror(errno)); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: can't open input file %s: %s\n", infilename, strerror(errno)); return 1; } } @@ -1701,7 +1707,7 @@ } else { if(!strncmp((const char *)lookahead, "ID3", 3)) { - flac__utils_printf(stderr, 1, "ERROR: input file %s has an ID3v2 tag\n", infilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: input file %s has an ID3v2 tag\n", infilename); return 1; } else if(!strncmp((const char *)lookahead, "RIFF", 4) && !strncmp((const char *)lookahead+8, "WAVE", 4)) @@ -1746,7 +1752,7 @@ if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (off_t)(-1)) { if(input_format == FORMAT_FLAC) { /* need more detailed error message when re-flac'ing to avoid confusing the user */ - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: output file %s already exists.\n\n" "By default flac encodes files to FLAC format; if you meant to decode this file\n" "from FLAC to something else, use -d. If you meant to re-encode this file from\n" @@ -1757,7 +1763,7 @@ } else if(input_format == FORMAT_OGGFLAC) { /* need more detailed error message when re-flac'ing to avoid confusing the user */ - flac__utils_printf(stderr, 1, + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: output file %s already exists.\n\n" "By default 'flac -ogg' encodes files to Ogg FLAC format; if you meant to decode\n" "this file from Ogg FLAC to something else, use -d. If you meant to re-encode\n" @@ -1767,14 +1773,14 @@ ); } else - flac__utils_printf(stderr, 1, "ERROR: output file %s already exists, use -f to override\n", outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: output file %s already exists, use -f to override\n", outfilename); conditional_fclose(encode_infile); return 1; } if(option_values.format_input_size >= 0) { if (input_format != FORMAT_RAW || infilesize >= 0) { - flac__utils_printf(stderr, 1, "ERROR: can only use --input-size when encoding raw samples from stdin\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: can only use --input-size when encoding raw samples from stdin\n"); conditional_fclose(encode_infile); return 1; } @@ -1784,12 +1790,12 @@ } if(option_values.sector_align && (input_format == FORMAT_FLAC || input_format == FORMAT_OGGFLAC)) { - flac__utils_printf(stderr, 1, "ERROR: can't use --sector-align when the input file is FLAC or Ogg FLAC\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: can't use --sector-align when the input file is FLAC or Ogg FLAC\n"); conditional_fclose(encode_infile); return 1; } if(option_values.sector_align && input_format == FORMAT_RAW && infilesize < 0) { - flac__utils_printf(stderr, 1, "ERROR: can't use --sector-align when the input size is unknown\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: can't use --sector-align when the input size is unknown\n"); conditional_fclose(encode_infile); return 1; } @@ -1869,7 +1875,7 @@ static const char *tmp_suffix = ".tmp,fl-ac+en'c"; /*@@@@ still a remote possibility that a file with this filename exists */ if(0 == (internal_outfilename = (char *)safe_malloc_add_3op_(strlen(outfilename), /*+*/strlen(tmp_suffix), /*+*/1))) { - flac__utils_printf(stderr, 1, "ERROR allocating memory for tempfile name\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR allocating memory for tempfile name\n"); conditional_fclose(encode_infile); return 1; } @@ -1895,7 +1901,7 @@ /* read foreign metadata if requested */ if(option_values.keep_foreign_metadata) { if(0 == (encode_options.format_options.iff.foreign_metadata = flac__foreign_metadata_new(input_format==FORMAT_WAVE? FOREIGN_BLOCK_TYPE__RIFF : FOREIGN_BLOCK_TYPE__AIFF))) { - flac__utils_printf(stderr, 1, "ERROR: creating foreign metadata object\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: creating foreign metadata object\n"); conditional_fclose(encode_infile); return 1; } @@ -1921,7 +1927,7 @@ 0 != (error = grabbag__replaygain_store_to_file_reference(internal_outfilename? internal_outfilename : outfilename, option_values.preserve_modtime)) || 0 != (error = grabbag__replaygain_store_to_file_title(internal_outfilename? internal_outfilename : outfilename, title_gain, title_peak, option_values.preserve_modtime)) ) { - flac__utils_printf(stderr, 1, "%s: ERROR writing ReplayGain reference/title tags (%s)\n", outfilename, error); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: ERROR writing ReplayGain reference/title tags (%s)\n", outfilename, error); retval = 1; } } @@ -1936,15 +1942,15 @@ #if defined _MSC_VER || defined __MINGW32__ || defined __EMX__ /* on some flavors of windows, rename() will fail if the destination already exists, so we unlink and try again */ if(unlink(outfilename) < 0) { - flac__utils_printf(stderr, 1, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, keeping both\n", internal_outfilename, outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, keeping both\n", internal_outfilename, outfilename); retval = 1; } else if(rename(internal_outfilename, outfilename) < 0) { - flac__utils_printf(stderr, 1, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, you must do it\n", internal_outfilename, outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, you must do it\n", internal_outfilename, outfilename); retval = 1; } #else - flac__utils_printf(stderr, 1, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, keeping both\n", internal_outfilename, outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: moving new FLAC file %s back on top of original FLAC file %s, keeping both\n", internal_outfilename, outfilename); retval = 1; #endif } @@ -1969,7 +1975,7 @@ const char *outfilename = get_decoded_outfilename(infilename); if(0 == outfilename) { - flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", infilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: filename too long: %s", infilename); return 1; } @@ -1978,7 +1984,7 @@ * Use grabbag__file_get_filesize() as a cheap way to check. */ if(!option_values.test_only && !option_values.force_file_overwrite && strcmp(outfilename, "-") && grabbag__file_get_filesize(outfilename) != (off_t)(-1)) { - flac__utils_printf(stderr, 1, "ERROR: output file %s already exists, use -f to override\n", outfilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: output file %s already exists, use -f to override\n", outfilename); return 1; } @@ -2016,7 +2022,7 @@ #if !FLAC__HAS_OGG if(treat_as_ogg) { - flac__utils_printf(stderr, 1, "%s: Ogg support has not been built into this copy of flac\n", infilename); + flac__utils_printf(stderr, VERBOSITY_SILENT, "%s: Ogg support has not been built into this copy of flac\n", infilename); return 1; } #endif @@ -2066,7 +2072,7 @@ /* read foreign metadata if requested */ if(option_values.keep_foreign_metadata) { if(0 == (options.foreign_metadata = flac__foreign_metadata_new(output_format==FORMAT_WAVE? FOREIGN_BLOCK_TYPE__RIFF : FOREIGN_BLOCK_TYPE__AIFF))) { - flac__utils_printf(stderr, 1, "ERROR: creating foreign metadata object\n"); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: creating foreign metadata object\n"); return 1; } } @@ -2148,7 +2154,7 @@ void die(const char *message) { FLAC__ASSERT(0 != message); - flac__utils_printf(stderr, 1, "ERROR: %s\n", message); + flac__utils_printf(stderr, VERBOSITY_SILENT, "ERROR: %s\n", message); exit(1); } Index: src/flac/utils.c =================================================================== RCS file: /cvsroot/flac/flac/src/flac/utils.c,v retrieving revision 1.15 diff -u -r1.15 utils.c --- src/flac/utils.c 28 Feb 2008 05:34:26 -0000 1.15 +++ src/flac/utils.c 15 May 2008 15:11:55 -0000 @@ -31,7 +31,7 @@ const char *CHANNEL_MASK_TAG = "WAVEFORMATEXTENSIBLE_CHANNEL_MASK"; -int flac__utils_verbosity_ = 2; +int flac__utils_verbosity_ = VERBOSITY_NO_SILENT; static FLAC__bool local__parse_uint64_(const char *s, FLAC__uint64 *value) { Index: src/flac/utils.h =================================================================== RCS file: /cvsroot/flac/flac/src/flac/utils.h,v retrieving revision 1.13 diff -u -r1.13 utils.h --- src/flac/utils.h 28 Feb 2008 05:34:26 -0000 1.13 +++ src/flac/utils.h 15 May 2008 15:11:55 -0000 @@ -51,6 +51,7 @@ #endif extern int flac__utils_verbosity_; +typedef enum {VERBOSITY_TOTALLY_SILENT, VERBOSITY_SILENT, VERBOSITY_PROGRESS_SILENT, VERBOSITY_NO_SILENT} VerbosityLevels; void flac__utils_printf(FILE *stream, int level, const char *format, ...); FLAC__bool flac__utils_parse_skip_until_specification(const char *s, utils__SkipUntilSpecification *spec);