]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
afh: Implement --human option.
authorAndre Noll <maan@systemlinux.org>
Sun, 6 Dec 2009 14:17:22 +0000 (15:17 +0100)
committerAndre Noll <maan@systemlinux.org>
Sun, 6 Dec 2009 14:17:22 +0000 (15:17 +0100)
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
ggo/afh.m4

diff --git a/afh.c b/afh.c
index c00644939d1bdd04f5010729715af874725f4a86..7fc32cd1c583a035475888cf7ed69473b3402d84 100644 (file)
--- 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)
index 97b8f2888fdb7f1bb88ec9906d2c5e1e551aa261..80df8948dd79962e149679d98444364ffdb75023 100644 (file)
@@ -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"
 #================================