From 3ade72ad746e4d38c1507feee9f4cb1ba0e7b035 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 6 Dec 2009 15:17:22 +0100 Subject: [PATCH] afh: Implement --human option. During debugging or when analyzing corrupt audio files, it is somethimes handy to look at the chunk table. This option makes it much easier for the human eye to spot e.g. huge chunks of an audio file which are sometimes caused by incomplete downloads. --- afh.c | 23 +++++++++++++++++++---- ggo/afh.m4 | 14 ++++++++++++++ 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/afh.c b/afh.c index c0064493..7fc32cd1 100644 --- a/afh.c +++ b/afh.c @@ -62,10 +62,25 @@ static void print_chunk_table(struct afh_info *afhi) { int i; - printf("chunk_table: "); - for (i = 0; i <= afhi->chunks_total; i++) - printf("%u ", afhi->chunk_table[i]); - printf("\n"); + if (!conf.human_given) { + printf("chunk_table: "); + for (i = 0; i <= afhi->chunks_total; i++) + printf("%u ", afhi->chunk_table[i]); + printf("\n"); + return; + } + for (i = 1; i <= afhi->chunks_total; i++) { + struct timeval tv; + long unsigned from, to; + tv_scale(i - 1, &afhi->chunk_tv, &tv); + from = tv2ms(&tv); + tv_scale(i, &afhi->chunk_tv, &tv); + to = tv2ms(&tv); + printf("%d [%lu.%03lu - %lu.%03lu] %u - %u (%u)\n", i, + from / 1000, from % 1000, to / 1000, to % 1000, + afhi->chunk_table[i - 1], afhi->chunk_table[i], + afhi->chunk_table[i] - afhi->chunk_table[i - 1]); + } } static int cat_file(void *audio_file_data, struct afh_info *afhi) diff --git a/ggo/afh.m4 b/ggo/afh.m4 index 97b8f288..80df8948 100644 --- a/ggo/afh.m4 +++ b/ggo/afh.m4 @@ -62,6 +62,20 @@ option "chunk_table" c flag off dependon="info" +option "human" u +#~~~~~~~~~~~~~~~ +"use human-readable output format" +flag off +dependon = "info" +details = " + Currently this option only affects the format of the chunk table, + so it has no effect if --chunk_table is not given. + + The human-readable output consists of one output line per + chunk and the output contains also the chunk number, the + duration and the size of each chunk. +" + section "Options for stream mode" #================================ -- 2.39.5