Commit 373efef4 authored by Michael Smith's avatar Michael Smith
Browse files

Fix problems concerning console output (writing too long lines, and writing

stuff when in quiet mode).

svn path=/trunk/vorbis-tools/; revision=2054
parent 00e0f29b
......@@ -366,9 +366,7 @@ int wav_open(FILE *in, oe_enc_opt *opt, unsigned char *oldbuf, int buflen)
if(len!=16)
fprintf(stderr,
"Warning: INVALID format chunk in wav header.\n"
" Trying to read anyway (may not work)...\n"
" The program that created this wav file is broken.\n"
" Don't use it, or report a bug.\n");
" Trying to read anyway (may not work)...\n");
if(fread(buf,1,16,in) < 16)
{
......
......@@ -45,6 +45,8 @@ int oe_encode(oe_enc_opt *opt)
/* get start time. */
timer = timer_start();
opt->start_encode(opt->infilename, opt->filename, opt->bitrate,
opt->quality);
/* Have vorbisenc choose a mode for us */
vorbis_info_init(&vi);
......@@ -211,8 +213,7 @@ void update_statistics_full(char *fn, long total, long done, double time)
minutes = ((int)remain_time)/60;
seconds = (int)(remain_time - (double)((int)remain_time/60)*60);
fprintf(stderr, "\rEncoding %s%s%s [%5.1f%%] [%2dm%.2ds remaining] %c",
fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
fprintf(stderr, "\r\t[%5.1f%%] [%2dm%.2ds remaining] %c",
done*100.0/total, minutes, seconds, spinner[spinpoint++%4]);
}
......@@ -221,8 +222,8 @@ void update_statistics_notime(char *fn, long total, long done, double time)
static char *spinner="|/-\\";
static int spinpoint =0;
fprintf(stderr, "\rEncoding %s%s%s %c",
fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
fprintf(stderr, "\r\tEncoding [%2dm%.2ds so far] %c",
((int)time)/60, (int)(time - (double)((int)time/60)*60),
spinner[spinpoint++%4]);
}
......@@ -273,5 +274,23 @@ void encode_error(char *errmsg)
fprintf(stderr, "\n%s\n", errmsg);
}
void start_encode_full(char *fn, char *outfn, int bitrate, float quality)
{
if(quality >= 0.0f)
fprintf(stderr, "Encoding %s%s%s to \n %s%s%s at quality %f\n",
fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
outfn?"\"":"", outfn?outfn:"standard output", outfn?"\"":"",
quality);
else
fprintf(stderr, "Encoding %s%s%s to \n "
"%s%s%s at bitrate %d kbps\n",
fn?"\"":"", fn?fn:"standard input", fn?"\"":"",
outfn?"\"":"", outfn?outfn:"standard output", outfn?"\"":"",
bitrate);
}
void start_encode_null(char *fn, char *outfn, int bitrate, float quality)
{
}
......@@ -11,6 +11,8 @@ typedef void (*progress_func)(char *fn, long totalsamples,
long samples, double time);
typedef void (*enc_end_func)(char *fn, double time, int rate,
long samples, long bytes);
typedef void (*enc_start_func)(char *fn, char *outfn, int bitrate,
float quality);
typedef void (*error_func)(char *errormessage);
......@@ -21,6 +23,8 @@ void timer_clear(void *);
void update_statistics_full(char *fn, long total, long done, double time);
void update_statistics_notime(char *fn, long total, long done, double time);
void update_statistics_null(char *fn, long total, long done, double time);
void start_encode_full(char *fn, char *outfn, int bitrate, float quality);
void start_encode_null(char *fn, char *outfn, int bitrate, float quality);
void final_statistics(char *fn, double time, int rate, long total_samples,
long bytes);
void final_statistics_null(char *fn, double time, int rate, long total_samples,
......@@ -70,6 +74,7 @@ typedef struct
audio_read_func read_samples;
progress_func progress_update;
enc_end_func end_encode;
enc_start_func start_encode;
error_func error;
void *readdata;
......@@ -85,6 +90,7 @@ typedef struct
FILE *out;
char *filename;
char *infilename;
} oe_enc_opt;
......
......@@ -122,6 +122,7 @@ int main(int argc, char **argv)
enc_opts.serialno = opt.serial++;
enc_opts.progress_update = update_statistics_full;
enc_opts.start_encode = start_encode_full;
enc_opts.end_encode = final_statistics;
enc_opts.error = encode_error;
......@@ -132,6 +133,7 @@ int main(int argc, char **argv)
{
setbinmode(stdin);
in = stdin;
infiles[i] = NULL;
if(!opt.outfile)
{
setbinmode(stdout);
......@@ -170,8 +172,9 @@ int main(int argc, char **argv)
format = open_audio_file(in, &enc_opts);
if(format)
{
fprintf(stderr, "Opening with %s module: %s\n",
format->format, format->description);
if(!opt.quiet)
fprintf(stderr, "Opening with %s module: %s\n",
format->format, format->description);
foundformat=1;
}
......@@ -240,6 +243,7 @@ int main(int argc, char **argv)
enc_opts.out = out;
enc_opts.comments = &vc;
enc_opts.filename = out_fn;
enc_opts.infilename = infiles[i];
enc_opts.bitrate = opt.nominal_bitrate;
enc_opts.min_bitrate = opt.min_bitrate;
enc_opts.max_bitrate = opt.max_bitrate;
......@@ -250,6 +254,7 @@ int main(int argc, char **argv)
if(opt.quiet)
{
enc_opts.start_encode = start_encode_null;
enc_opts.progress_update = update_statistics_null;
enc_opts.end_encode = final_statistics_null;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment