X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afh.c;h=e6c46c3f9d68471ad31529205a46d4590a92b985;hp=8975777bdb549ae68bc0fc125be7e959b4253ecc;hb=792936cec17542777826e5fce4cfe520a984bba2;hpb=2b12fc963d15219721dd23eb7947bf516f2ad574 diff --git a/afh.c b/afh.c index 8975777b..e6c46c3f 100644 --- a/afh.c +++ b/afh.c @@ -17,8 +17,10 @@ #include "version.h" #include "ggo.h" +/** Array of error strings. */ +DEFINE_PARA_ERRLIST; + static struct afh_args_info conf; -INIT_AFH_ERRLISTS; static int loglevel; INIT_STDERR_LOGGING(loglevel) @@ -123,29 +125,38 @@ static void print_info(int audio_format_num, struct afh_info *afhi) free(msg); } -static void print_chunk_table(struct afh_info *afhi) +static void print_chunk_table(struct afh_info *afhi, int audio_format_id, + const void *map, size_t mapsize) { - int i; + int i, ret; + void *ctx = NULL; - if (conf.parser_friendly_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++) { + for (i = 0; i < afhi->chunks_total; i++) { struct timeval tv; long unsigned from, to; - tv_scale(i - 1, &afhi->chunk_tv, &tv); - from = tv2ms(&tv); + const char *buf; + size_t len; tv_scale(i, &afhi->chunk_tv, &tv); + from = tv2ms(&tv); + tv_scale(i + 1, &afhi->chunk_tv, &tv); to = tv2ms(&tv); - printf("%d [%lu.%03lu - %lu.%03lu] %u - %u (%u)\n", i - 1, - 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]); + ret = afh_get_chunk(i, afhi, audio_format_id, map, mapsize, + &buf, &len, &ctx); + if (ret < 0) { + PARA_ERROR_LOG("fatal: chunk %d: %s\n", i, + para_strerror(-ret)); + return; + } + if (!conf.parser_friendly_given) + printf("%d [%lu.%03lu - %lu.%03lu] ", i, from / 1000, + from % 1000, to / 1000, to % 1000); + printf("%td - %td", buf - (const char *)map, + buf + len - (const char *)map); + if (!conf.parser_friendly_given) + printf(" (%zu)", len); + printf("\n"); } + afh_close(ctx, audio_format_id); } __noreturn static void print_help_and_die(void) @@ -199,8 +210,8 @@ int main(int argc, char **argv) printf("File %d: %s\n", i + 1, conf.inputs[i]); print_info(audio_format_num, &afhi); if (conf.chunk_table_given) - print_chunk_table(&afhi); - printf("\n"); + print_chunk_table(&afhi, audio_format_num, + audio_file_data, audio_file_size); } clear_afhi(&afhi); }