FLAC__bool is_ogg;
#endif
- FLAC__bool verbose;
- FLAC__bool silent;
FLAC__bool is_aiff_out;
FLAC__bool is_wave_out;
FLAC__bool continue_through_decode_errors;
/*
* local routines
*/
-static FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool verbose, FLAC__bool silent, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename);
+static FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename);
static void DecoderSession_destroy(DecoderSession *d, FLAC__bool error_occurred);
static FLAC__bool DecoderSession_init_decoder(DecoderSession *d, decode_options_t decode_options, const char *infilename);
static FLAC__bool DecoderSession_process(DecoderSession *d);
static int DecoderSession_finish_ok(DecoderSession *d);
static int DecoderSession_finish_error(DecoderSession *d);
-static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input, FLAC__bool silent);
+static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input);
static FLAC__bool write_necessary_headers(DecoderSession *decoder_session);
static FLAC__bool write_little_endian_uint16(FILE *f, FLAC__uint16 val);
static FLAC__bool write_little_endian_uint32(FILE *f, FLAC__uint32 val);
static FLAC__bool write_big_endian_uint16(FILE *f, FLAC__uint16 val);
static FLAC__bool write_big_endian_uint32(FILE *f, FLAC__uint32 val);
static FLAC__bool write_sane_extended(FILE *f, unsigned val);
-static FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out, unsigned riff_offset, unsigned data_offset, unsigned frames_offset, FLAC__uint32 total_samples, unsigned channels, unsigned bps, FLAC__bool silent);
+static FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out, unsigned riff_offset, unsigned data_offset, unsigned frames_offset, FLAC__uint32 total_samples, unsigned channels, unsigned bps);
/*
* We use 'void *' so that we can use the same callbacks for the
* FLAC__StreamDecoder and FLAC__FileDecoder. The 'decoder' argument is
#else
/*is_ogg=*/false,
#endif
- options.common.verbose,
- options.common.silent,
/*is_aiff_out=*/true,
/*is_wave_out=*/false,
options.common.continue_through_decode_errors,
#else
/*is_ogg=*/false,
#endif
- options.common.verbose,
- options.common.silent,
/*is_aiff_out=*/false,
/*is_wave_out=*/true,
options.common.continue_through_decode_errors,
#else
/*is_ogg=*/false,
#endif
- options.common.verbose,
- options.common.silent,
/*is_aiff_out=*/false,
/*is_wave_out=*/false,
options.common.continue_through_decode_errors,
return DecoderSession_finish_ok(&decoder_session);
}
-FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool verbose, FLAC__bool silent, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename)
+FLAC__bool DecoderSession_construct(DecoderSession *d, FLAC__bool is_ogg, FLAC__bool is_aiff_out, FLAC__bool is_wave_out, FLAC__bool continue_through_decode_errors, replaygain_synthesis_spec_t replaygain_synthesis_spec, FLAC__bool analysis_mode, analysis_options aopts, utils__SkipUntilSpecification *skip_specification, utils__SkipUntilSpecification *until_specification, utils__CueSpecification *cue_specification, const char *infilename, const char *outfilename)
{
#ifdef FLAC__HAS_OGG
d->is_ogg = is_ogg;
(void)is_ogg;
#endif
- d->verbose = verbose;
- d->silent = silent;
d->is_aiff_out = is_aiff_out;
d->is_wave_out = is_wave_out;
d->continue_through_decode_errors = continue_through_decode_errors;
}
else {
if(0 == (d->fout = fopen(outfilename, "wb"))) {
- if(!d->silent) fprintf(stderr, "%s: ERROR: can't open output file %s\n", d->inbasefilename, outfilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: can't open output file %s\n", d->inbasefilename, outfilename);
DecoderSession_destroy(d, /*error_occurred=*/true);
return false;
}
decoder_session->decoder.ogg.file = OggFLAC__file_decoder_new();
if(0 == decoder_session->decoder.ogg.file) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR creating the decoder instance\n", decoder_session->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR creating the decoder instance\n", decoder_session->inbasefilename);
return false;
}
decoder_session->decoder.flac.file = FLAC__file_decoder_new();
if(0 == decoder_session->decoder.flac.file) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR creating the decoder instance\n", decoder_session->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR creating the decoder instance\n", decoder_session->inbasefilename);
return false;
}
#ifdef FLAC__HAS_OGG
if(d->is_ogg) {
if(!OggFLAC__file_decoder_process_until_end_of_metadata(d->decoder.ogg.file)) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR while decoding metadata");
return false;
}
if(OggFLAC__file_decoder_get_state(d->decoder.ogg.file) != OggFLAC__FILE_DECODER_OK && OggFLAC__file_decoder_get_state(d->decoder.ogg.file) != OggFLAC__FILE_DECODER_END_OF_FILE) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR during metadata decoding");
return false;
}
#endif
{
if(!FLAC__file_decoder_process_until_end_of_metadata(d->decoder.flac.file)) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR while decoding metadata");
return false;
}
if(FLAC__file_decoder_get_state(d->decoder.flac.file) != FLAC__FILE_DECODER_OK && FLAC__file_decoder_get_state(d->decoder.flac.file) != FLAC__FILE_DECODER_END_OF_FILE) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR during metadata decoding");
return false;
}
return false;
}
if(!OggFLAC__file_decoder_process_until_end_of_file(d->decoder.ogg.file) && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR while decoding frames");
return false;
}
if(OggFLAC__file_decoder_get_state(d->decoder.ogg.file) != OggFLAC__FILE_DECODER_OK && OggFLAC__file_decoder_get_state(d->decoder.ogg.file) != OggFLAC__FILE_DECODER_END_OF_FILE && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR during decoding");
return false;
}
return false;
}
if(!FLAC__file_decoder_process_until_end_of_file(d->decoder.flac.file) && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR while decoding frames");
return false;
}
if(FLAC__file_decoder_get_state(d->decoder.flac.file) != FLAC__FILE_DECODER_OK && FLAC__file_decoder_get_state(d->decoder.flac.file) != FLAC__FILE_DECODER_END_OF_FILE && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR during decoding");
return false;
}
#ifdef FLAC__HAS_OGG
if(d->is_ogg) {
if(!OggFLAC__file_decoder_process_until_end_of_file(d->decoder.ogg.file) && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR while decoding data");
return false;
}
if(OggFLAC__file_decoder_get_state(d->decoder.ogg.file) != OggFLAC__FILE_DECODER_OK && OggFLAC__file_decoder_get_state(d->decoder.ogg.file) != OggFLAC__FILE_DECODER_END_OF_FILE && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR during decoding");
return false;
}
#endif
{
if(!FLAC__file_decoder_process_until_end_of_file(d->decoder.flac.file) && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR while decoding data");
return false;
}
if(FLAC__file_decoder_get_state(d->decoder.flac.file) != FLAC__FILE_DECODER_OK && FLAC__file_decoder_get_state(d->decoder.flac.file) != FLAC__FILE_DECODER_END_OF_FILE && !d->aborting_due_to_until) {
- if(d->verbose) fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
print_error_with_state(d, "ERROR during decoding");
return false;
}
if(d->analysis_mode)
flac__analyze_finish(d->aopts);
if(md5_failure) {
- if(!d->silent) fprintf(stderr, "\r%s: WARNING, MD5 signature mismatch\n", d->inbasefilename);
+ flac__utils_printf(stderr, 1, "\r%s: WARNING, MD5 signature mismatch\n", d->inbasefilename);
}
else {
- if(d->verbose) fprintf(stderr, "\r%s: %s \n", d->inbasefilename, d->test_only? "ok ":d->analysis_mode?"done ":"done");
+ flac__utils_printf(stderr, 2, "\r%s: %s \n", d->inbasefilename, d->test_only? "ok ":d->analysis_mode?"done ":"done");
}
DecoderSession_destroy(d, /*error_occurred=*/false);
if((d->is_wave_out || d->is_aiff_out) && d->wave_chunk_size_fixup.needs_fixup)
- if(!fixup_wave_chunk_size(d->outfilename, d->is_wave_out, d->wave_chunk_size_fixup.riff_offset, d->wave_chunk_size_fixup.data_offset, d->wave_chunk_size_fixup.frames_offset, (FLAC__uint32)d->samples_processed, d->channels, d->bps, d->silent))
+ if(!fixup_wave_chunk_size(d->outfilename, d->is_wave_out, d->wave_chunk_size_fixup.riff_offset, d->wave_chunk_size_fixup.data_offset, d->wave_chunk_size_fixup.frames_offset, (FLAC__uint32)d->samples_processed, d->channels, d->bps))
return 1;
return 0;
}
return 1;
}
-FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input, FLAC__bool silent)
+FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input)
{
/* convert from mm:ss.sss to sample number if necessary */
flac__utils_canonicalize_skip_until_specification(spec, sample_rate);
/* in any other case the total samples in the input must be known */
if(total_samples_in_input == 0) {
- if(!silent) fprintf(stderr, "%s: ERROR, cannot use --until when FLAC metadata has total sample count of 0\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until when FLAC metadata has total sample count of 0\n", inbasefilename);
return false;
}
/* error check */
if(spec->value.samples < 0) {
- if(!silent) fprintf(stderr, "%s: ERROR, --until value is before beginning of input\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before beginning of input\n", inbasefilename);
return false;
}
if((FLAC__uint64)spec->value.samples <= skip) {
- if(!silent) fprintf(stderr, "%s: ERROR, --until value is before --skip point\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before --skip point\n", inbasefilename);
return false;
}
if((FLAC__uint64)spec->value.samples > total_samples_in_input) {
- if(!silent) fprintf(stderr, "%s: ERROR, --until value is after end of input\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, --until value is after end of input\n", inbasefilename);
return false;
}
FLAC__uint64 data_size = decoder_session->total_samples * decoder_session->channels * ((decoder_session->bps+7)/8);
if(decoder_session->total_samples == 0) {
if(decoder_session->fout == stdout) {
- if(!decoder_session->silent) fprintf(stderr, "%s: WARNING, don't have accurate sample count available for %s header.\n", decoder_session->inbasefilename, fmt_desc);
- if(!decoder_session->silent) fprintf(stderr, " Generated %s file will have a data chunk size of 0. Try\n", fmt_desc);
- if(!decoder_session->silent) fprintf(stderr, " decoding directly to a file instead.\n");
+ 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");
}
else {
decoder_session->wave_chunk_size_fixup.needs_fixup = true;
}
}
if(data_size >= 0xFFFFFFDC) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR: stream is too big to fit in a single %s file chunk\n", decoder_session->inbasefilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "%s: ERROR: stream is too big to fit in a single %s file chunk\n", decoder_session->inbasefilename, fmt_desc);
return false;
}
if(decoder_session->is_wave_out) {
return true;
}
-FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out, unsigned riff_offset, unsigned data_offset, unsigned frames_offset, FLAC__uint32 total_samples, unsigned channels, unsigned bps, FLAC__bool silent)
+FLAC__bool fixup_wave_chunk_size(const char *outfilename, FLAC__bool is_wave_out, unsigned riff_offset, unsigned data_offset, unsigned frames_offset, FLAC__uint32 total_samples, unsigned channels, unsigned bps)
{
const char *fmt_desc = (is_wave_out? "WAVE" : "AIFF");
FLAC__bool (*write_it)(FILE *, FLAC__uint32) = (is_wave_out? write_little_endian_uint32 : write_big_endian_uint32);
FLAC__uint32 data_size, aligned_data_size;
if(0 == f) {
- if(!silent) fprintf(stderr, "ERROR, couldn't open file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "ERROR, couldn't open file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
return false;
}
aligned_data_size++;
if(fseek(f, riff_offset, SEEK_SET) < 0) {
- if(!silent) fprintf(stderr, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
fclose(f);
return false;
}
if(!write_it(f, aligned_data_size + (is_wave_out? 36 : 46))) {
- if(!silent) fprintf(stderr, "ERROR, couldn't write size in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "ERROR, couldn't write size in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
fclose(f);
return false;
}
if(!is_wave_out) {
if(fseek(f, frames_offset, SEEK_SET) < 0) {
- if(!silent) fprintf(stderr, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
fclose(f);
return false;
}
if(!write_it(f, total_samples)) {
- if(!silent) fprintf(stderr, "ERROR, couldn't write size in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "ERROR, couldn't write size in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
fclose(f);
return false;
}
}
if(fseek(f, data_offset, SEEK_SET) < 0) {
- if(!silent) fprintf(stderr, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "ERROR, couldn't seek in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
fclose(f);
return false;
}
if(!write_it(f, data_size + (is_wave_out? 0 : 8))) {
- if(!silent) fprintf(stderr, "ERROR, couldn't write size in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
+ flac__utils_printf(stderr, 1, "ERROR, couldn't write size in file %s while fixing up %s chunk size\n", outfilename, fmt_desc);
fclose(f);
return false;
}
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
if(bps != decoder_session->bps) {
- if(!decoder_session->silent) fprintf(stderr, "%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, 1, "%s: ERROR, bits-per-sample is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, bps, decoder_session->bps);
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
if(channels != decoder_session->channels) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR, channels is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, channels, decoder_session->channels);
+ flac__utils_printf(stderr, 1, "%s: ERROR, channels is %u in frame but %u in STREAMINFO\n", decoder_session->inbasefilename, channels, decoder_session->channels);
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
if(frame->header.sample_rate != decoder_session->sample_rate) {
- if(!decoder_session->silent) fprintf(stderr, "%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, 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);
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
}
decoder_session->samples_processed += wide_samples;
decoder_session->frame_counter++;
- if(decoder_session->verbose && !(decoder_session->frame_counter & 0x3f))
+ if(!(decoder_session->frame_counter & 0x3f))
print_stats(decoder_session);
if(decoder_session->analysis_mode) {
/* 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) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR trying to --skip more samples than in stream\n", decoder_session->inbasefilename);
+ flac__utils_printf(stderr, 1, "%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) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR, can't --skip when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, can't --skip when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename);
decoder_session->abort_flag = true;
return;
}
decoder_session->total_samples = metadata->data.stream_info.total_samples - skip;
/* note that we use metadata->data.stream_info.total_samples instead of decoder_session->total_samples */
- if(!canonicalize_until_specification(decoder_session->until_specification, decoder_session->inbasefilename, decoder_session->sample_rate, skip, metadata->data.stream_info.total_samples, decoder_session->silent)) {
+ if(!canonicalize_until_specification(decoder_session->until_specification, decoder_session->inbasefilename, decoder_session->sample_rate, skip, metadata->data.stream_info.total_samples)) {
decoder_session->abort_flag = true;
return;
}
}
if(decoder_session->bps != 8 && decoder_session->bps != 16 && decoder_session->bps != 24) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR: bits per sample is not 8/16/24\n", decoder_session->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: bits per sample is not 8/16/24\n", decoder_session->inbasefilename);
decoder_session->abort_flag = true;
return;
}
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) {
- if(!decoder_session->silent) fprintf(stderr, "%s: ERROR can't use --cue when FLAC metadata has total sample count of 0\n", decoder_session->inbasefilename);
+ flac__utils_printf(stderr, 1, "%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;
}
if (decoder_session->replaygain.spec.apply) {
double gain, peak;
if (!(decoder_session->replaygain.apply = grabbag__replaygain_load_from_vorbiscomment(metadata, decoder_session->replaygain.spec.use_album_gain, &gain, &peak))) {
- if(!decoder_session->silent) fprintf(stderr, "%s: WARNING: can't get %s ReplayGain tag\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track");
+ flac__utils_printf(stderr, 1, "%s: WARNING: can't get %s ReplayGain tag\n", decoder_session->inbasefilename, decoder_session->replaygain.spec.use_album_gain? "album":"track");
}
else {
const char *ls[] = { "no", "peak", "hard" };
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);
- if(!decoder_session->silent) fprintf(stderr, "%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]);
- if(!decoder_session->silent) fprintf(stderr, "%s: WARNING: applying ReplayGain is not lossless\n", decoder_session->inbasefilename);
+ 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);
}
}
}
{
DecoderSession *decoder_session = (DecoderSession*)client_data;
(void)decoder;
- if(!decoder_session->silent) fprintf(stderr, "%s: *** Got error code %d:%s\n", decoder_session->inbasefilename, status, FLAC__StreamDecoderErrorStatusString[status]);
+ flac__utils_printf(stderr, 1, "%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;
}
{
const int ilen = strlen(d->inbasefilename) + 1;
- if(d->silent)
- return;
-
- fprintf(stderr, "\n%s: %s\n", d->inbasefilename, message);
+ flac__utils_printf(stderr, 1, "\n%s: %s\n", d->inbasefilename, message);
#ifdef FLAC__HAS_OGG
if(d->is_ogg) {
const OggFLAC__FileDecoderState ofd_state = OggFLAC__file_decoder_get_state(d->decoder.ogg.file);
if(ofd_state != OggFLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR) {
- fprintf(stderr, "%*s state = %d:%s\n", ilen, "", (int)ofd_state, OggFLAC__FileDecoderStateString[ofd_state]);
+ flac__utils_printf(stderr, 1, "%*s state = %d:%s\n", ilen, "", (int)ofd_state, OggFLAC__FileDecoderStateString[ofd_state]);
}
else {
const OggFLAC__SeekableStreamDecoderState ossd_state = OggFLAC__file_decoder_get_seekable_stream_decoder_state(d->decoder.ogg.file);
if(ossd_state != OggFLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR) {
- fprintf(stderr, "%*s state = %d:%s\n", ilen, "", (int)ossd_state, OggFLAC__SeekableStreamDecoderStateString[ossd_state]);
+ flac__utils_printf(stderr, 1, "%*s state = %d:%s\n", ilen, "", (int)ossd_state, OggFLAC__SeekableStreamDecoderStateString[ossd_state]);
}
else {
const OggFLAC__StreamDecoderState osd_state = OggFLAC__file_decoder_get_state(d->decoder.ogg.file);
if(osd_state != OggFLAC__STREAM_DECODER_FLAC_STREAM_DECODER_ERROR) {
- fprintf(stderr, "%*s state = %d:%s\n", ilen, "", (int)osd_state, OggFLAC__StreamDecoderStateString[osd_state]);
+ flac__utils_printf(stderr, 1, "%*s state = %d:%s\n", ilen, "", (int)osd_state, OggFLAC__StreamDecoderStateString[osd_state]);
}
else {
const FLAC__StreamDecoderState fsd_state = OggFLAC__file_decoder_get_FLAC_stream_decoder_state(d->decoder.ogg.file);
- fprintf(stderr, "%*s state = %d:%s\n", ilen, "", (int)fsd_state, FLAC__StreamDecoderStateString[fsd_state]);
+ flac__utils_printf(stderr, 1, "%*s state = %d:%s\n", ilen, "", (int)fsd_state, FLAC__StreamDecoderStateString[fsd_state]);
}
}
}
{
const FLAC__FileDecoderState ffd_state = FLAC__file_decoder_get_state(d->decoder.flac.file);
if(ffd_state != FLAC__FILE_DECODER_SEEKABLE_STREAM_DECODER_ERROR) {
- fprintf(stderr, "%*s state = %d:%s\n", ilen, "", (int)ffd_state, FLAC__FileDecoderStateString[ffd_state]);
+ flac__utils_printf(stderr, 1, "%*s state = %d:%s\n", ilen, "", (int)ffd_state, FLAC__FileDecoderStateString[ffd_state]);
}
else {
const FLAC__SeekableStreamDecoderState fssd_state = FLAC__file_decoder_get_seekable_stream_decoder_state(d->decoder.flac.file);
if(fssd_state != FLAC__SEEKABLE_STREAM_DECODER_STREAM_DECODER_ERROR) {
- fprintf(stderr, "%*s state = %d:%s\n", ilen, "", (int)fssd_state, FLAC__SeekableStreamDecoderStateString[fssd_state]);
+ flac__utils_printf(stderr, 1, "%*s state = %d:%s\n", ilen, "", (int)fssd_state, FLAC__SeekableStreamDecoderStateString[fssd_state]);
}
else {
const FLAC__StreamDecoderState fsd_state = FLAC__file_decoder_get_stream_decoder_state(d->decoder.flac.file);
- fprintf(stderr, "%*s state = %d:%s\n", ilen, "", (int)fsd_state, FLAC__StreamDecoderStateString[fsd_state]);
+ flac__utils_printf(stderr, 1, "%*s state = %d:%s\n", ilen, "", (int)fsd_state, FLAC__StreamDecoderStateString[fsd_state]);
}
}
}
void print_stats(const DecoderSession *decoder_session)
{
- if(decoder_session->verbose) {
+ if(flac__utils_verbosity_ >= 2) {
#if defined _MSC_VER || defined __MINGW32__
/* with VC++ 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;
#endif
#include <limits.h> /* for LONG_MAX */
#include <math.h> /* for floor() */
-#include <stdarg.h>
#include <stdio.h> /* for FILE etc. */
#include <stdlib.h> /* for malloc */
#include <string.h> /* for strcmp() */
FLAC__bool use_ogg;
#endif
FLAC__bool verify;
- FLAC__bool verbose;
- FLAC__bool silent;
FLAC__bool is_stdout;
const char *inbasefilename;
const char *outfilename;
/*
* local routines
*/
-static FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool verbose, FLAC__bool silent, FILE *infile, const char *infilename, const char *outfilename);
+static FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FILE *infile, const char *infilename, const char *outfilename);
static void EncoderSession_destroy(EncoderSession *e);
static int EncoderSession_finish_ok(EncoderSession *e, int info_align_carry, int info_align_zero);
static int EncoderSession_finish_error(EncoderSession *e);
static FLAC__bool EncoderSession_init_encoder(EncoderSession *e, encode_options_t options, unsigned channels, unsigned bps, unsigned sample_rate);
static FLAC__bool EncoderSession_process(EncoderSession *e, const FLAC__int32 * const buffer[], unsigned samples);
static FLAC__bool convert_to_seek_table_template(const char *requested_seek_points, int num_requested_seek_points, FLAC__StreamMetadata *cuesheet, EncoderSession *e);
-static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input, FLAC__bool silent);
+static FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input);
static void format_input(FLAC__int32 *dest[], unsigned wide_samples, FLAC__bool is_big_endian, FLAC__bool is_unsigned_samples, unsigned channels, unsigned bps);
#ifdef FLAC__HAS_OGG
static FLAC__StreamEncoderWriteStatus ogg_stream_encoder_write_callback(const OggFLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
static FLAC__StreamEncoderWriteStatus flac_stream_encoder_write_callback(const FLAC__StreamEncoder *encoder, const FLAC__byte buffer[], unsigned bytes, unsigned samples, unsigned current_frame, void *client_data);
static void flac_stream_encoder_metadata_callback(const FLAC__StreamEncoder *encoder, const FLAC__StreamMetadata *metadata, void *client_data);
static void flac_file_encoder_progress_callback(const FLAC__FileEncoder *encoder, FLAC__uint64 bytes_written, FLAC__uint64 samples_written, unsigned frames_written, unsigned total_frames_estimate, void *client_data);
-static FLAC__bool parse_cuesheet_(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool silent);
+static FLAC__bool parse_cuesheet_(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset);
static void print_stats(const EncoderSession *encoder_session);
static void print_error_with_state(const EncoderSession *e, const char *message);
static void print_verify_error(EncoderSession *e);
-static FLAC__bool read_little_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent);
-static FLAC__bool read_little_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent);
-static FLAC__bool read_big_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent);
-static FLAC__bool read_big_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent);
-static FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent);
+static FLAC__bool read_little_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn);
+static FLAC__bool read_little_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn);
+static FLAC__bool read_big_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn);
+static FLAC__bool read_big_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn);
+static FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn);
/*
* public routines
/*use_ogg=*/false,
#endif
options.common.verify,
- options.common.verbose,
- options.common.silent,
infile,
infilename,
outfilename
if(feof(infile) || ((c= fread(chunk_id, 1U, 4U, infile)), c==0U && feof(infile)))
break;
else if(c<4U || feof(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: incomplete chunk identifier\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: incomplete chunk identifier\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
unsigned long skip;
/* COMM chunk size */
- if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else if(xx<18U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: non-standard 'COMM' chunk has length = %u\n", encoder_session.inbasefilename, (unsigned int)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: non-standard 'COMM' chunk has length = %u\n", encoder_session.inbasefilename, (unsigned int)xx);
return EncoderSession_finish_error(&encoder_session);
}
else if(xx!=18U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: non-standard 'COMM' chunk has length = %u\n", encoder_session.inbasefilename, (unsigned int)xx);
+ flac__utils_printf(stderr, 1, "%s: WARNING: non-standard 'COMM' chunk has length = %u\n", encoder_session.inbasefilename, (unsigned int)xx);
}
skip= (xx-18U)+(xx & 1U);
/* number of channels */
- if(!read_big_endian_uint16(infile, &x, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint16(infile, &x, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else if(x==0U || x>FLAC__MAX_CHANNELS) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported number channels %u\n", encoder_session.inbasefilename, (unsigned int)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number channels %u\n", encoder_session.inbasefilename, (unsigned int)x);
return EncoderSession_finish_error(&encoder_session);
}
else if(options.common.sector_align && x!=2U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, (unsigned int)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, (unsigned int)x);
return EncoderSession_finish_error(&encoder_session);
}
channels= x;
/* number of sample frames */
- if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
sample_frames= xx;
/* bits per sample */
- if(!read_big_endian_uint16(infile, &x, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint16(infile, &x, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else if(x!=8U && x!=16U && x!=24U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported bits per sample %u\n", encoder_session.inbasefilename, (unsigned int)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported bits per sample %u\n", encoder_session.inbasefilename, (unsigned int)x);
return EncoderSession_finish_error(&encoder_session);
}
else if(options.common.sector_align && x!=16U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: file has %u bits per sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, (unsigned int)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: file has %u bits per sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, (unsigned int)x);
return EncoderSession_finish_error(&encoder_session);
}
bps= x;
/* sample rate */
- if(!read_sane_extended(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_sane_extended(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else if(!FLAC__format_sample_rate_is_valid(xx)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported sample rate %u\n", encoder_session.inbasefilename, (unsigned int)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported sample rate %u\n", encoder_session.inbasefilename, (unsigned int)xx);
return EncoderSession_finish_error(&encoder_session);
}
else if(options.common.sector_align && xx!=44100U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, (unsigned int)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, (unsigned int)xx);
return EncoderSession_finish_error(&encoder_session);
}
sample_rate= xx;
while(skip>0U && fseek(infile, skip, SEEK_CUR)<0) {
unsigned int need= min(skip, sizeof ucbuffer_);
if(fread(ucbuffer_, 1U, need, infile)<need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping extra COMM data\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping extra COMM data\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
skip-= need;
FLAC__bool pad= false;
if(got_comm_chunk==false) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: got 'SSND' chunk before 'COMM' chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: got 'SSND' chunk before 'COMM' chunk\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
/* SSND chunk size */
- if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else if(xx!=(sample_frames*bytes_per_frame + 8U)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: SSND chunk size inconsistent with sample frame count\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: SSND chunk size inconsistent with sample frame count\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
data_bytes= xx;
data_bytes-= 8U; /* discount the offset and block size fields */
/* offset */
- if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else if(xx!=0U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: offset is %u; must be 0\n", encoder_session.inbasefilename, (unsigned int)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: offset is %u; must be 0\n", encoder_session.inbasefilename, (unsigned int)xx);
return EncoderSession_finish_error(&encoder_session);
}
offset= xx;
/* block size */
- if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else if(xx!=0U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: block size is %u; must be 0\n", encoder_session.inbasefilename, (unsigned int)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: block size is %u; must be 0\n", encoder_session.inbasefilename, (unsigned int)xx);
return EncoderSession_finish_error(&encoder_session);
}
block_size= xx;
* now that we know the input size, canonicalize the
* --until string to an absolute sample number:
*/
- if(!canonicalize_until_specification(&options.common.until_specification, encoder_session.inbasefilename, sample_rate, encoder_session.skip, total_samples_in_input, encoder_session.silent))
+ if(!canonicalize_until_specification(&options.common.until_specification, encoder_session.inbasefilename, sample_rate, encoder_session.skip, total_samples_in_input))
return EncoderSession_finish_error(&encoder_session);
encoder_session.until = (FLAC__uint64)options.common.until_specification.value.samples;
FLAC__ASSERT(!options.common.sector_align || encoder_session.until == 0);
while(skip>0 && fseek(infile, skip, SEEK_CUR)<0) {
unsigned int need= min(skip, sizeof ucbuffer_);
if(fread(ucbuffer_, 1U, need, infile)<need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
skip-= need;
if(bytes_read==0U) {
if(ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else if(feof(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+ flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
data_bytes= 0;
}
}
else {
if(bytes_read % bytes_per_frame != 0U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else {
while(skip>0 && fseek(infile, skip, SEEK_CUR)<0) {
unsigned int need= min(skip, sizeof ucbuffer_);
if(fread(ucbuffer_, 1U, need, infile)<need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
skip-= need;
FLAC__ASSERT(CHUNK_OF_SAMPLES>=588U);
if(bytes_read==0U && ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_frame) {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)bytes_read, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
+ flac__utils_printf(stderr, 1, "%s: WARNING: unexpected EOF; read %u bytes; expected %u samples, got %u samples\n", encoder_session.inbasefilename, (unsigned int)bytes_read, (unsigned int)encoder_session.total_samples_to_encode, (unsigned int)encoder_session.samples_written);
}
else {
info_align_carry= *options.common.align_reservoir_samples;
unsigned char tmp;
if(fread(&tmp, 1U, 1U, infile)<1U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read of SSND pad byte\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read of SSND pad byte\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
}
}
else { /* other chunk */
if(!strncmp(chunk_id, "COMM", 4)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: skipping extra 'COMM' chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'COMM' chunk\n", encoder_session.inbasefilename);
}
else if(!strncmp(chunk_id, "SSND", 4)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: skipping extra 'SSND' chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'SSND' chunk\n", encoder_session.inbasefilename);
}
else {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: skipping unknown chunk '%s'\n", encoder_session.inbasefilename, chunk_id);
+ flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown chunk '%s'\n", encoder_session.inbasefilename, chunk_id);
}
/* chunk size */
- if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_big_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
else {
unsigned long skip= xx+(xx & 1U);
}
if(got_ssnd_chunk==false && sample_frames!=0U) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: missing SSND chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: missing SSND chunk\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
/*use_ogg=*/false,
#endif
options.common.verify,
- options.common.verbose,
- options.common.silent,
infile,
infilename,
outfilename
* lookahead[] already has "RIFFxxxxWAVE", do sub-chunks
*/
while(!feof(infile)) {
- if(!read_little_endian_uint32(infile, &xx, true, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint32(infile, &xx, true, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
if(feof(infile))
break;
unsigned block_align;
/* fmt sub-chunk size */
- if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
if(xx < 16) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: found non-standard 'fmt ' sub-chunk which has length = %u\n", encoder_session.inbasefilename, (unsigned)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: found non-standard 'fmt ' sub-chunk which has length = %u\n", encoder_session.inbasefilename, (unsigned)xx);
return EncoderSession_finish_error(&encoder_session);
}
else if(xx != 16 && xx != 18) {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: found non-standard 'fmt ' sub-chunk which has length = %u\n", encoder_session.inbasefilename, (unsigned)xx);
+ flac__utils_printf(stderr, 1, "%s: WARNING: found non-standard 'fmt ' sub-chunk which has length = %u\n", encoder_session.inbasefilename, (unsigned)xx);
}
data_bytes = xx;
/* compression code */
- if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
if(x != 1) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported compression type %u\n", encoder_session.inbasefilename, (unsigned)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported compression type %u\n", encoder_session.inbasefilename, (unsigned)x);
return EncoderSession_finish_error(&encoder_session);
}
/* number of channels */
- if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
if(x == 0 || x > FLAC__MAX_CHANNELS) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported number channels %u\n", encoder_session.inbasefilename, (unsigned)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported number channels %u\n", encoder_session.inbasefilename, (unsigned)x);
return EncoderSession_finish_error(&encoder_session);
}
else if(options.common.sector_align && x != 2) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, (unsigned)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: file has %u channels, must be 2 for --sector-align\n", encoder_session.inbasefilename, (unsigned)x);
return EncoderSession_finish_error(&encoder_session);
}
channels = x;
/* sample rate */
- if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
if(!FLAC__format_sample_rate_is_valid(xx)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported sample rate %u\n", encoder_session.inbasefilename, (unsigned)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported sample rate %u\n", encoder_session.inbasefilename, (unsigned)xx);
return EncoderSession_finish_error(&encoder_session);
}
else if(options.common.sector_align && xx != 44100) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, (unsigned)xx);
+ flac__utils_printf(stderr, 1, "%s: ERROR: file's sample rate is %u, must be 44100 for --sector-align\n", encoder_session.inbasefilename, (unsigned)xx);
return EncoderSession_finish_error(&encoder_session);
}
sample_rate = xx;
/* avg bytes per second (ignored) */
- if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
/* block align */
- if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
block_align = x;
/* bits per sample */
- if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint16(infile, &x, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
if(x != 8 && x != 16 && x != 24) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported bits-per-sample %u\n", encoder_session.inbasefilename, (unsigned)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported bits-per-sample %u\n", encoder_session.inbasefilename, (unsigned)x);
return EncoderSession_finish_error(&encoder_session);
}
else if(options.common.sector_align && x != 16) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: file has %u bits per sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, (unsigned)x);
+ flac__utils_printf(stderr, 1, "%s: ERROR: file has %u bits per sample, must be 16 for --sector-align\n", encoder_session.inbasefilename, (unsigned)x);
return EncoderSession_finish_error(&encoder_session);
}
bps = x;
if(bps * channels != block_align * 8) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: unsupported block alignment (%u), for bits-per-sample=%u, channels=%u\n", encoder_session.inbasefilename, block_align, bps, channels);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unsupported block alignment (%u), for bits-per-sample=%u, channels=%u\n", encoder_session.inbasefilename, block_align, bps, channels);
return EncoderSession_finish_error(&encoder_session);
}
is_unsigned_samples = (x == 8);
for(left = data_bytes; left > 0; ) {
need = min(left, CHUNK_OF_SAMPLES);
if(fread(ucbuffer_, 1U, need, infile) < need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
left -= need;
FLAC__uint64 total_samples_in_input, trim = 0;
/* data size */
- if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
data_bytes = xx;
* now that we know the input size, canonicalize the
* --until string to an absolute sample number:
*/
- if(!canonicalize_until_specification(&options.common.until_specification, encoder_session.inbasefilename, sample_rate, encoder_session.skip, total_samples_in_input, encoder_session.silent))
+ if(!canonicalize_until_specification(&options.common.until_specification, encoder_session.inbasefilename, sample_rate, encoder_session.skip, total_samples_in_input))
return EncoderSession_finish_error(&encoder_session);
encoder_session.until = (FLAC__uint64)options.common.until_specification.value.samples;
FLAC__ASSERT(!options.common.sector_align || encoder_session.until == 0);
for(left = (unsigned)encoder_session.skip; left > 0; ) { /*@@@ WATCHOUT: 4GB limit */
need = min(left, CHUNK_OF_SAMPLES);
if(fread(ucbuffer_, bytes_per_wide_sample, need, infile) < need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
left -= need;
bytes_read = fread(ucbuffer_, sizeof(unsigned char), min(data_bytes, CHUNK_OF_SAMPLES * bytes_per_wide_sample), infile);
if(bytes_read == 0) {
if(ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else if(feof(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%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, 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);
data_bytes = 0;
}
}
else {
if(bytes_read % bytes_per_wide_sample != 0) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else {
for(left = (unsigned)trim; left > 0; ) { /*@@@ WATCHOUT: 4GB limit */
need = min(left, CHUNK_OF_SAMPLES);
if(fread(ucbuffer_, bytes_per_wide_sample, need, infile) < need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
left -= need;
FLAC__ASSERT(CHUNK_OF_SAMPLES >= 588);
bytes_read = fread(ucbuffer_, sizeof(unsigned char), (*options.common.align_reservoir_samples) * bytes_per_wide_sample, infile);
if(bytes_read == 0 && ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
- if(!encoder_session.silent) fprintf(stderr, "%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, 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);
data_bytes = 0;
}
else {
}
else {
if(xx == 0x20746d66 && got_fmt_chunk) { /* "fmt " */
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: skipping extra 'fmt ' sub-chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'fmt ' sub-chunk\n", encoder_session.inbasefilename);
}
else if(xx == 0x61746164) { /* "data" */
if(got_data_chunk) {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: skipping extra 'data' sub-chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: WARNING: skipping extra 'data' sub-chunk\n", encoder_session.inbasefilename);
}
else if(!got_fmt_chunk) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: got 'data' sub-chunk before 'fmt' sub-chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: got 'data' sub-chunk before 'fmt' sub-chunk\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else {
}
}
else {
- if(!encoder_session.silent) fprintf(stderr, "%s: WARNING: skipping unknown sub-chunk '%c%c%c%c'\n", encoder_session.inbasefilename, (char)(xx&255), (char)((xx>>8)&255), (char)((xx>>16)&255), (char)(xx>>24));
+ flac__utils_printf(stderr, 1, "%s: WARNING: skipping unknown sub-chunk '%c%c%c%c'\n", encoder_session.inbasefilename, (char)(xx&255), (char)((xx>>8)&255), (char)((xx>>16)&255), (char)(xx>>24));
}
/* sub-chunk size */
- if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename, encoder_session.silent))
+ if(!read_little_endian_uint32(infile, &xx, false, encoder_session.inbasefilename))
return EncoderSession_finish_error(&encoder_session);
if(fseek(infile, xx, SEEK_CUR) < 0) {
/* can't seek input, read ahead manually... */
for(left = xx; left > 0; ) {
need = min(left, chunk);
if(fread(ucbuffer_, 1, need, infile) < need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping unsupported sub-chunk\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping unsupported sub-chunk\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
left -= need;
/*use_ogg=*/false,
#endif
options.common.verify,
- options.common.verbose,
- options.common.silent,
infile,
infilename,
outfilename
* now that we know the input size, canonicalize the
* --until strings to a number of samples:
*/
- if(!canonicalize_until_specification(&options.common.until_specification, encoder_session.inbasefilename, options.sample_rate, encoder_session.skip, total_samples_in_input, encoder_session.silent))
+ if(!canonicalize_until_specification(&options.common.until_specification, encoder_session.inbasefilename, options.sample_rate, encoder_session.skip, total_samples_in_input))
return EncoderSession_finish_error(&encoder_session);
encoder_session.until = (FLAC__uint64)options.common.until_specification.value.samples;
FLAC__ASSERT(!options.common.sector_align || encoder_session.until == 0);
}
encoder_session.unencoded_size = encoder_session.total_samples_to_encode * bytes_per_wide_sample;
- if(encoder_session.verbose && encoder_session.total_samples_to_encode <= 0)
- fprintf(stderr, "(No runtime statistics possible; please wait for encoding to finish...)\n");
+ if(encoder_session.total_samples_to_encode <= 0)
+ flac__utils_printf(stderr, 2, "(No runtime statistics possible; please wait for encoding to finish...)\n");
if(encoder_session.skip > 0) {
unsigned skip_bytes = bytes_per_wide_sample * (unsigned)encoder_session.skip;
for(left = skip_bytes; left > 0; ) {
need = min(left, chunk);
if(fread(ucbuffer_, 1, need, infile) < need) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read while skipping samples\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
left -= need;
memcpy(ucbuffer_, lookahead, lookahead_length);
bytes_read = fread(ucbuffer_+lookahead_length, sizeof(unsigned char), CHUNK_OF_SAMPLES * bytes_per_wide_sample - lookahead_length, infile) + lookahead_length;
if(ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
lookahead_length = 0;
if(bytes_read == 0) {
if(ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
}
else if(bytes_read % bytes_per_wide_sample != 0) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else {
if(wanted > 0) {
bytes_read += fread(ucbuffer_+lookahead_length, sizeof(unsigned char), wanted, infile);
if(ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
}
if(bytes_read == 0) {
if(ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else if(feof(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%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, 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);
total_input_bytes_read = max_input_bytes;
}
}
else {
if(bytes_read % bytes_per_wide_sample != 0) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR: got partial sample\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else {
FLAC__ASSERT(CHUNK_OF_SAMPLES >= 588);
bytes_read = fread(ucbuffer_, sizeof(unsigned char), (*options.common.align_reservoir_samples) * bytes_per_wide_sample, infile);
if(bytes_read == 0 && ferror(infile)) {
- if(!encoder_session.silent) fprintf(stderr, "%s: ERROR during read\n", encoder_session.inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR during read\n", encoder_session.inbasefilename);
return EncoderSession_finish_error(&encoder_session);
}
else if(bytes_read != (*options.common.align_reservoir_samples) * bytes_per_wide_sample) {
- if(!encoder_session.silent) fprintf(stderr, "%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, 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);
}
else {
info_align_carry = *options.common.align_reservoir_samples;
return EncoderSession_finish_ok(&encoder_session, info_align_carry, info_align_zero);
}
-FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FLAC__bool verbose, FLAC__bool silent, FILE *infile, const char *infilename, const char *outfilename)
+FLAC__bool EncoderSession_construct(EncoderSession *e, FLAC__bool use_ogg, FLAC__bool verify, FILE *infile, const char *infilename, const char *outfilename)
{
unsigned i;
FLAC__uint32 test = 1;
(void)use_ogg;
#endif
e->verify = verify;
- e->verbose = verbose;
- e->silent = silent;
e->is_stdout = (0 == strcmp(outfilename, "-"));
}
if(0 == (e->seek_table_template = FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE))) {
- if(!e->silent) fprintf(stderr, "%s: ERROR allocating memory for seek table\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for seek table\n", e->inbasefilename);
return false;
}
if(e->is_stdout) {
e->encoder.ogg.stream = OggFLAC__stream_encoder_new();
if(0 == e->encoder.ogg.stream) {
- if(!e->silent) fprintf(stderr, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
EncoderSession_destroy(e);
return false;
}
else {
e->encoder.ogg.file = OggFLAC__file_encoder_new();
if(0 == e->encoder.ogg.file) {
- if(!e->silent) fprintf(stderr, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
EncoderSession_destroy(e);
return false;
}
if(e->is_stdout) {
e->encoder.flac.stream = FLAC__stream_encoder_new();
if(0 == e->encoder.flac.stream) {
- if(!e->silent) fprintf(stderr, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
EncoderSession_destroy(e);
return false;
}
else {
e->encoder.flac.file = FLAC__file_encoder_new();
if(0 == e->encoder.flac.file) {
- if(!e->silent) fprintf(stderr, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR creating the encoder instance\n", e->inbasefilename);
EncoderSession_destroy(e);
return false;
}
}
}
- if(e->verbose && e->total_samples_to_encode > 0) {
+ if(e->total_samples_to_encode > 0) {
print_stats(e);
- fprintf(stderr, "\n");
+ flac__utils_printf(stderr, 2, "\n");
}
if(fse_state == FLAC__STREAM_ENCODER_VERIFY_MISMATCH_IN_AUDIO_DATA) {
}
else {
if(info_align_carry >= 0) {
- if(!e->silent) fprintf(stderr, "%s: INFO: sector alignment causing %d samples to be carried over\n", e->inbasefilename, info_align_carry);
+ flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d samples to be carried over\n", e->inbasefilename, info_align_carry);
}
if(info_align_zero >= 0) {
- if(!e->silent) fprintf(stderr, "%s: INFO: sector alignment causing %d zero samples to be appended\n", e->inbasefilename, info_align_zero);
+ flac__utils_printf(stderr, 1, "%s: INFO: sector alignment causing %d zero samples to be appended\n", e->inbasefilename, info_align_zero);
}
}
{
FLAC__StreamEncoderState fse_state;
- if(e->verbose && e->total_samples_to_encode > 0)
- fprintf(stderr, "\n");
+ if(e->total_samples_to_encode > 0)
+ flac__utils_printf(stderr, 2, "\n");
#ifdef FLAC__HAS_OGG
if(e->use_ogg) {
if(e->replay_gain) {
if(channels != 1 && channels != 2) {
- if(!e->silent) fprintf(stderr, "%s: ERROR, number of channels (%u) must be 1 or 2 for --replay-gain\n", e->inbasefilename, channels);
+ flac__utils_printf(stderr, 1, "%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)) {
- if(!e->silent) fprintf(stderr, "%s: ERROR, invalid sample rate (%u) for --replay-gain\n", e->inbasefilename, sample_rate);
+ flac__utils_printf(stderr, 1, "%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)) {
- if(!e->silent) fprintf(stderr, "%s: ERROR initializing ReplayGain stage\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR initializing ReplayGain stage\n", e->inbasefilename);
return false;
}
}
if(channels != 2)
options.do_mid_side = options.loose_mid_side = false;
- if(!parse_cuesheet_(&cuesheet, options.cuesheet_filename, e->inbasefilename, is_cdda, e->total_samples_to_encode, e->silent))
+ if(!parse_cuesheet_(&cuesheet, options.cuesheet_filename, e->inbasefilename, is_cdda, e->total_samples_to_encode))
return false;
if(!convert_to_seek_table_template(options.requested_seek_points, options.num_requested_seek_points, options.cued_seekpoints? cuesheet : 0, e)) {
- if(!e->silent) fprintf(stderr, "%s: ERROR allocating memory for seek table\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR allocating memory for seek table\n", e->inbasefilename);
if(0 != cuesheet)
free(cuesheet);
return false;
{
if(e->replay_gain) {
if(!grabbag__replaygain_analyze(buffer, e->channels==2, e->bits_per_sample, samples)) {
- if(!e->silent) fprintf(stderr, "%s: WARNING, error while calculating ReplayGain\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: WARNING, error while calculating ReplayGain\n", e->inbasefilename);
}
}
if(has_real_points) {
if(e->is_stdout) {
- if(!e->silent) fprintf(stderr, "%s: WARNING, cannot write back seekpoints when encoding to stdout\n", e->inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: WARNING, cannot write back seekpoints when encoding to stdout\n", e->inbasefilename);
}
}
return true;
}
-FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input, FLAC__bool silent)
+FLAC__bool canonicalize_until_specification(utils__SkipUntilSpecification *spec, const char *inbasefilename, unsigned sample_rate, FLAC__uint64 skip, FLAC__uint64 total_samples_in_input)
{
/* convert from mm:ss.sss to sample number if necessary */
flac__utils_canonicalize_skip_until_specification(spec, sample_rate);
/* in any other case the total samples in the input must be known */
if(total_samples_in_input == 0) {
- if(!silent) fprintf(stderr, "%s: ERROR, cannot use --until when input length is unknown\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, cannot use --until when input length is unknown\n", inbasefilename);
return false;
}
/* error check */
if(spec->value.samples < 0) {
- if(!silent) fprintf(stderr, "%s: ERROR, --until value is before beginning of input\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before beginning of input\n", inbasefilename);
return false;
}
if((FLAC__uint64)spec->value.samples <= skip) {
- if(!silent) fprintf(stderr, "%s: ERROR, --until value is before --skip point\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, --until value is before --skip point\n", inbasefilename);
return false;
}
if((FLAC__uint64)spec->value.samples > total_samples_in_input) {
- if(!silent) fprintf(stderr, "%s: ERROR, --until value is after end of input\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR, --until value is after end of input\n", inbasefilename);
return false;
}
(void)samples;
encoder_session->samples_written = (current_frame+1) * encoder_session->blocksize;
- if(encoder_session->verbose && encoder_session->total_samples_to_encode > 0 && !(current_frame & encoder_session->stats_mask))
+ if(encoder_session->total_samples_to_encode > 0 && !(current_frame & encoder_session->stats_mask))
print_stats(encoder_session);
if(flac__utils_fwrite(buffer, sizeof(FLAC__byte), bytes, encoder_session->fout) == bytes)
encoder_session->bytes_written += bytes;
encoder_session->samples_written += samples;
- if(samples && encoder_session->verbose && encoder_session->total_samples_to_encode > 0 && !(current_frame & encoder_session->stats_mask))
+ if(samples && encoder_session->total_samples_to_encode > 0 && !(current_frame & encoder_session->stats_mask))
print_stats(encoder_session);
if(flac__utils_fwrite(buffer, sizeof(FLAC__byte), bytes, encoder_session->fout) == bytes)
encoder_session->bytes_written = bytes_written;
encoder_session->samples_written = samples_written;
- if(encoder_session->verbose && encoder_session->total_samples_to_encode > 0 && !((frames_written-1) & encoder_session->stats_mask))
+ if(encoder_session->total_samples_to_encode > 0 && !((frames_written-1) & encoder_session->stats_mask))
print_stats(encoder_session);
}
-FLAC__bool parse_cuesheet_(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset, FLAC__bool silent)
+FLAC__bool parse_cuesheet_(FLAC__StreamMetadata **cuesheet, const char *cuesheet_filename, const char *inbasefilename, FLAC__bool is_cdda, FLAC__uint64 lead_out_offset)
{
FILE *f;
unsigned last_line_read;
return true;
if(lead_out_offset == 0) {
- if(!silent) fprintf(stderr, "%s: ERROR cannot import cuesheet when the number of input samples to encode is unknown\n", inbasefilename);
+ flac__utils_printf(stderr, 1, "%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"))) {
- if(!silent) fprintf(stderr, "%s: ERROR opening cuesheet \"%s\" for reading\n", inbasefilename, cuesheet_filename);
+ flac__utils_printf(stderr, 1, "%s: ERROR opening cuesheet \"%s\" for reading\n", inbasefilename, cuesheet_filename);
return false;
}
fclose(f);
if(0 == *cuesheet) {
- if(!silent) fprintf(stderr, "%s: ERROR parsing cuesheet \"%s\" on line %u: %s\n", inbasefilename, cuesheet_filename, last_line_read, error_message);
+ flac__utils_printf(stderr, 1, "%s: ERROR parsing cuesheet \"%s\" on line %u: %s\n", inbasefilename, cuesheet_filename, last_line_read, error_message);
return false;
}
const double ratio = (double)encoder_session->bytes_written / ((double)encoder_session->unencoded_size * min(1.0, progress));
#endif
- if(encoder_session->silent)
- return;
if(samples_written == encoder_session->total_samples_to_encode) {
- fprintf(stderr, "\r%s:%s wrote %u bytes, ratio=%0.3f",
+ flac__utils_printf(stderr, 2, "\r%s:%s wrote %u bytes, ratio=%0.3f",
encoder_session->inbasefilename,
encoder_session->verify? " Verify OK," : "",
(unsigned)encoder_session->bytes_written,
);
}
else {
- fprintf(stderr, "\r%s: %u%% complete, ratio=%0.3f", encoder_session->inbasefilename, (unsigned)floor(progress * 100.0 + 0.5), ratio);
+ flac__utils_printf(stderr, 2, "\r%s: %u%% complete, ratio=%0.3f", encoder_session->inbasefilename, (unsigned)floor(progress * 100.0 + 0.5), ratio);
}
}
const int ilen = strlen(e->inbasefilename) + 1;
const char *state_string;
- if(e->silent)
- return;
-
fprintf(stderr, "\n%s: %s\n", e->inbasefilename, message);
#ifdef FLAC__HAS_OGG
state_string = FLAC__file_encoder_get_resolved_state_string(e->encoder.flac.file);
}
- fprintf(stderr, "%*s state = %s\n", ilen, "", state_string);
+ flac__utils_printf(stderr, 1, "%*s state = %s\n", ilen, "", state_string);
}
void print_verify_error(EncoderSession *e)
FLAC__int32 expected;
FLAC__int32 got;
- if(e->silent)
- return;
-
#ifdef FLAC__HAS_OGG
if(e->use_ogg) {
if(e->is_stdout) {
FLAC__file_encoder_get_verify_decoder_error_stats(e->encoder.flac.file, &absolute_sample, &frame_number, &channel, &sample, &expected, &got);
}
- fprintf(stderr, "%s: ERROR: mismatch in decoded data, verify FAILED!\n", e->inbasefilename);
- fprintf(stderr, " Absolute sample=%u, frame=%u, channel=%u, sample=%u, expected %d, got %d\n", (unsigned)absolute_sample, frame_number, channel, sample, expected, got);
- fprintf(stderr, " Please submit a bug report to\n");
- fprintf(stderr, " http://sourceforge.net/bugs/?func=addbug&group_id=13478\n");
- fprintf(stderr, " Make sure to include an email contact in the comment and/or use the\n");
- fprintf(stderr, " \"Monitor\" feature to monitor the bug status.\n");
- fprintf(stderr, "Verify FAILED! Do not trust %s\n", e->outfilename);
+ 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, " Please submit a bug report to\n");
+ flac__utils_printf(stderr, 1, " http://sourceforge.net/bugs/?func=addbug&group_id=13478\n");
+ flac__utils_printf(stderr, 1, " Make sure to include an email contact in the comment and/or use the\n");
+ flac__utils_printf(stderr, 1, " \"Monitor\" feature to monitor the bug status.\n");
+ flac__utils_printf(stderr, 1, "Verify FAILED! Do not trust %s\n", e->outfilename);
}
-FLAC__bool read_little_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent)
+FLAC__bool read_little_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn)
{
size_t bytes_read = fread(val, 1, 2, f);
if(bytes_read == 0) {
if(!eof_ok) {
- if(!silent) fprintf(stderr, "%s: ERROR: unexpected EOF\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn);
return false;
}
else
return true;
}
else if(bytes_read < 2) {
- if(!silent) fprintf(stderr, "%s: ERROR: unexpected EOF\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn);
return false;
}
else {
}
}
-FLAC__bool read_little_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent)
+FLAC__bool read_little_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn)
{
size_t bytes_read = fread(val, 1, 4, f);
if(bytes_read == 0) {
if(!eof_ok) {
- if(!silent) fprintf(stderr, "%s: ERROR: unexpected EOF\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn);
return false;
}
else
return true;
}
else if(bytes_read < 4) {
- if(!silent) fprintf(stderr, "%s: ERROR: unexpected EOF\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn);
return false;
}
else {
}
}
-FLAC__bool read_big_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent)
+FLAC__bool read_big_endian_uint16(FILE *f, FLAC__uint16 *val, FLAC__bool eof_ok, const char *fn)
{
unsigned char buf[4];
size_t bytes_read= fread(buf, 1, 2, f);
if(bytes_read==0U && eof_ok)
return true;
else if(bytes_read<2U) {
- if(!silent) fprintf(stderr, "%s: ERROR: unexpected EOF\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn);
return false;
}
return true;
}
-FLAC__bool read_big_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent)
+FLAC__bool read_big_endian_uint32(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn)
{
unsigned char buf[4];
size_t bytes_read= fread(buf, 1, 4, f);
if(bytes_read==0U && eof_ok)
return true;
else if(bytes_read<4U) {
- if(!silent) fprintf(stderr, "%s: ERROR: unexpected EOF\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn);
return false;
}
return true;
}
-FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn, FLAC__bool silent)
+FLAC__bool read_sane_extended(FILE *f, FLAC__uint32 *val, FLAC__bool eof_ok, const char *fn)
/* Read an IEEE 754 80-bit (aka SANE) extended floating point value from 'f',
* convert it into an integral value and store in 'val'. Return false if only
* between 1 and 9 bytes remain in 'f', if 0 bytes remain in 'f' and 'eof_ok' is
if(bytes_read==0U && eof_ok)
return true;
else if(bytes_read<10U) {
- if(!silent) fprintf(stderr, "%s: ERROR: unexpected EOF\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: unexpected EOF\n", fn);
return false;
}
else if((buf[0]>>7)==1U || e<0 || e>63) {
- if(!silent) fprintf(stderr, "%s: ERROR: invalid floating-point value\n", fn);
+ flac__utils_printf(stderr, 1, "%s: ERROR: invalid floating-point value\n", fn);
return false;
}
FLAC__bool show_version;
FLAC__bool mode_decode;
FLAC__bool verify;
- FLAC__bool verbose;
- FLAC__bool silent;
FLAC__bool force_file_overwrite;
FLAC__bool continue_through_decode_errors;
replaygain_synthesis_spec_t replaygain_synthesis_spec;
setlocale(LC_ALL, "");
if(!init_options()) {
- if(!option_values.silent) fprintf(stderr, "ERROR: allocating memory\n");
+ flac__utils_printf(stderr, 1, "ERROR: allocating memory\n");
retval = 1;
}
else {
}
else {
if(option_values.num_files == 0) {
- if(!option_values.silent) short_usage();
+ if(flac__utils_verbosity_ >= 1)
+ short_usage();
return 0;
}
* whole file.
*/
if(option_values.padding < 0) {
- if(!option_values.silent) fprintf(stderr, "NOTE: --replay-gain may leave a small PADDING block even with --no-padding\n");
+ flac__utils_printf(stderr, 1, "NOTE: --replay-gain may leave a small PADDING block even with --no-padding\n");
option_values.padding = GRABBAG__REPLAYGAIN_MAX_TAG_SPACE_REQUIRED;
}
else {
return usage_error("ERROR: --cuesheet cannot be used when encoding multiple files\n");
}
}
- if(option_values.verbose) {
- fprintf(stderr, "\n");
- fprintf(stderr, "flac %s, Copyright (C) 2000,2001,2002,2003,2004 Josh Coalson\n", FLAC__VERSION_STRING);
- fprintf(stderr, "flac comes with ABSOLUTELY NO WARRANTY. This is free software, and you are\n");
- fprintf(stderr, "welcome to redistribute it under certain conditions. Type `flac' for details.\n\n");
- if(!option_values.mode_decode) {
- char padopt[16];
- if(option_values.padding < 0)
- strcpy(padopt, "-");
- else
- sprintf(padopt, " %d", option_values.padding);
- fprintf(stderr,
- "options:%s%s%s%s -P%s -b %u%s -l %u%s%s%s -q %u -r %u,%u%s\n",
- option_values.delete_input?" --delete-input-file":"",
- option_values.sector_align?" --sector-align":"",
- option_values.use_ogg?" --ogg":"",
- option_values.lax?" --lax":"",
- padopt,
- (unsigned)option_values.blocksize,
- option_values.loose_mid_side?" -M":option_values.do_mid_side?" -m":"",
- option_values.max_lpc_order,
- option_values.do_exhaustive_model_search?" -e":"",
- option_values.do_escape_coding?" -E":"",
- option_values.do_qlp_coeff_prec_search?" -p":"",
- option_values.qlp_coeff_precision,
- (unsigned)option_values.min_residual_partition_order,
- (unsigned)option_values.max_residual_partition_order,
- option_values.verify? " -V":""
- );
- }
+ flac__utils_printf(stderr, 2, "\n");
+ flac__utils_printf(stderr, 2, "flac %s, Copyright (C) 2000,2001,2002,2003,2004 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");
+
+ if(!option_values.mode_decode) {
+ char padopt[16];
+ if(option_values.padding < 0)
+ strcpy(padopt, "-");
+ else
+ sprintf(padopt, " %d", option_values.padding);
+ flac__utils_printf(stderr, 2,
+ "options:%s%s%s%s -P%s -b %u%s -l %u%s%s%s -q %u -r %u,%u%s\n",
+ option_values.delete_input?" --delete-input-file":"",
+ option_values.sector_align?" --sector-align":"",
+ option_values.use_ogg?" --ogg":"",
+ option_values.lax?" --lax":"",
+ padopt,
+ (unsigned)option_values.blocksize,
+ option_values.loose_mid_side?" -M":option_values.do_mid_side?" -m":"",
+ option_values.max_lpc_order,
+ option_values.do_exhaustive_model_search?" -e":"",
+ option_values.do_escape_coding?" -E":"",
+ option_values.do_qlp_coeff_prec_search?" -p":"",
+ option_values.qlp_coeff_precision,
+ (unsigned)option_values.min_residual_partition_order,
+ (unsigned)option_values.max_residual_partition_order,
+ option_values.verify? " -V":""
+ );
}
if(option_values.mode_decode) {
for(i = 0; i < option_values.num_files; i++) {
const char *error, *outfilename = get_encoded_outfilename(option_values.filenames[i]);
if(0 == outfilename) {
- if(!option_values.silent) fprintf(stderr, "ERROR: filename too long: %s", option_values.filenames[i]);
+ flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", option_values.filenames[i]);
return 1;
}
if(0 == strcmp(option_values.filenames[i], "-")) {
FLAC__ASSERT(0);
/* double protection */
- if(!option_values.silent) fprintf(stderr, "internal error\n");
+ flac__utils_printf(stderr, 1, "internal error\n");
return 2;
}
if(0 != (error = grabbag__replaygain_store_to_file_album(outfilename, album_gain, album_peak, /*preserve_modtime=*/true))) {
- if(!option_values.silent) fprintf(stderr, "%s: ERROR writing ReplayGain album tags\n", outfilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR writing ReplayGain album tags\n", outfilename);
retval = 1;
}
}
option_values.show_explain = false;
option_values.mode_decode = false;
option_values.verify = false;
- option_values.verbose = true;
- option_values.silent = false;
option_values.force_file_overwrite = false;
option_values.continue_through_decode_errors = false;
option_values.replaygain_synthesis_spec.apply = false;
if(short_option == 0) {
FLAC__ASSERT(0 != long_option);
if(0 == strcmp(long_option, "totally-silent")) {
- option_values.verbose = false;
- option_values.silent = true;
+ flac__utils_verbosity_ = 0;
}
else if(0 == strcmp(long_option, "delete-input-file")) {
option_values.delete_input = true;
option_values.continue_through_decode_errors = false;
}
else if(0 == strcmp(long_option, "no-silent")) {
- option_values.verbose = true;
- option_values.silent = false;
+ flac__utils_verbosity_ = 2;
}
else if(0 == strcmp(long_option, "no-force")) {
option_values.force_file_overwrite = false;
option_values.force_to_stdout = true;
break;
case 's':
- option_values.verbose = false;
+ flac__utils_verbosity_ = 1;
break;
case 'f':
option_values.force_file_overwrite = true;
int usage_error(const char *message, ...)
{
- if(!option_values.silent) {
+ if(flac__utils_verbosity_ >= 1) {
va_list args;
FLAC__ASSERT(0 != message);
void format_mistake(const char *infilename, const char *wrong, const char *right)
{
- if(!option_values.silent) fprintf(stderr, "WARNING: %s is not a %s file; treating as a %s file\n", infilename, wrong, right);
+ flac__utils_printf(stderr, 1, "WARNING: %s is not a %s file; treating as a %s file\n", infilename, wrong, right);
}
int encode_file(const char *infilename, FLAC__bool is_first_file, FLAC__bool is_last_file)
const char *outfilename = get_encoded_outfilename(infilename);
if(0 == outfilename) {
- if(!option_values.silent) fprintf(stderr, "ERROR: filename too long: %s", infilename);
+ flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", infilename);
return 1;
}
* Use grabbag__file_get_filesize() as a cheap way to check.
*/
if(!option_values.test_only && !option_values.force_file_overwrite && grabbag__file_get_filesize(outfilename) != (off_t)(-1)) {
- if(!option_values.silent) fprintf(stderr, "ERROR: output file %s already exists, use -f to override\n", outfilename);
+ flac__utils_printf(stderr, 1, "ERROR: output file %s already exists, use -f to override\n", outfilename);
return 1;
}
else {
infilesize = grabbag__file_get_filesize(infilename);
if(0 == (encode_infile = fopen(infilename, "rb"))) {
- if(!option_values.silent) fprintf(stderr, "ERROR: can't open input file %s\n", infilename);
+ flac__utils_printf(stderr, 1, "ERROR: can't open input file %s\n", infilename);
return 1;
}
}
}
if(option_values.sector_align && fmt == RAW && infilesize < 0) {
- if(!option_values.silent) fprintf(stderr, "ERROR: can't --sector-align when the input size is unknown\n");
+ flac__utils_printf(stderr, 1, "ERROR: can't --sector-align when the input size is unknown\n");
return 1;
}
if(0 == option_values.until_specification)
common_options.until_specification.is_relative = true;
- common_options.verbose = option_values.verbose;
- common_options.silent = option_values.silent;
common_options.verify = option_values.verify;
#ifdef FLAC__HAS_OGG
common_options.use_ogg = option_values.use_ogg;
const char *error;
grabbag__replaygain_get_title(&title_gain, &title_peak);
if(0 != (error = grabbag__replaygain_store_to_file_title(outfilename, title_gain, title_peak, /*preserve_modtime=*/true))) {
- if(!option_values.silent) fprintf(stderr, "%s: ERROR writing ReplayGain title tags\n", outfilename);
+ flac__utils_printf(stderr, 1, "%s: ERROR writing ReplayGain title tags\n", outfilename);
}
}
grabbag__file_copy_metadata(infilename, outfilename);
const char *outfilename = get_decoded_outfilename(infilename);
if(0 == outfilename) {
- if(!option_values.silent) fprintf(stderr, "ERROR: filename too long: %s", infilename);
+ flac__utils_printf(stderr, 1, "ERROR: filename too long: %s", infilename);
return 1;
}
* Use grabbag__file_get_filesize() as a cheap way to check.
*/
if(!option_values.test_only && !option_values.force_file_overwrite && grabbag__file_get_filesize(outfilename) != (off_t)(-1)) {
- if(!option_values.silent) fprintf(stderr, "ERROR: output file %s already exists, use -f to override\n", outfilename);
+ flac__utils_printf(stderr, 1, "ERROR: output file %s already exists, use -f to override\n", outfilename);
return 1;
}
#ifndef FLAC__HAS_OGG
if(treat_as_ogg) {
- if(!option_values.silent) fprintf(stderr, "%s: Ogg support has not been built into this copy of flac\n", infilename);
+ flac__utils_printf(stderr, 1, "%s: Ogg support has not been built into this copy of flac\n", infilename);
return 1;
}
#endif
else
common_options.has_cue_specification = false;
- common_options.verbose = option_values.verbose;
- common_options.silent = option_values.silent;
common_options.continue_through_decode_errors = option_values.continue_through_decode_errors;
common_options.replaygain_synthesis_spec = option_values.replaygain_synthesis_spec;
#ifdef FLAC__HAS_OGG
void die(const char *message)
{
FLAC__ASSERT(0 != message);
- if(!option_values.silent) fprintf(stderr, "ERROR: %s\n", message);
+ flac__utils_printf(stderr, 1, "ERROR: %s\n", message);
exit(1);
}