X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=afh.c;h=e6c46c3f9d68471ad31529205a46d4590a92b985;hp=36c432e54546d7f6079f9eb0ea4b35b675ab806b;hb=b6b571e6c6fb52207b11fc7833b272ec8cfa28bf;hpb=234647bb5139513bdf36c1afec46f5c43ba27adc diff --git a/afh.c b/afh.c index 36c432e5..e6c46c3f 100644 --- a/afh.c +++ b/afh.c @@ -125,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) @@ -201,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); }