X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;f=ogg_afh_common.c;h=0a27a4acebc1652da03dea1573bf337eaf9c52a9;hb=2934ee80367ee9d50b99ed8d7f672d1a397b4ce0;hp=4fc37952a61fcb92a8a6a9c74978b501525716bd;hpb=16f2ff3d3a6951588cd7a4ba1b33832a07b8652b;p=paraslash.git diff --git a/ogg_afh_common.c b/ogg_afh_common.c index 4fc37952..0a27a4ac 100644 --- a/ogg_afh_common.c +++ b/ogg_afh_common.c @@ -125,8 +125,8 @@ int oac_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, ogg_page op; char *buf; int ret, i, j, frames_per_chunk, ct_size, prev_pageno = 0; - long long unsigned granule = 0, granule_skip = 0, num_frames = 0; - int64_t prev_granule = 0; + long long unsigned granule_skip = 0, num_frames = 0; + int64_t granule = 0, prev_granule = 0; ogg_sync_init(&oss); ret = -E_OGG_SYNC; @@ -148,8 +148,9 @@ int oac_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, /* count ogg pages and get duration of the file */ for (i = 0; ogg_sync_pageseek(&oss, &op) > 0; i++) { int this_pageno = ogg_page_pageno(&op); - - granule = ogg_page_granulepos(&op); + int64_t this_granule = ogg_page_granulepos(&op); + if (this_granule >= 0) + granule = this_granule; if (i > 0 && this_pageno != prev_pageno + 1) /* hole */ granule_skip += granule - prev_granule; prev_pageno = this_pageno; @@ -166,7 +167,7 @@ int oac_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, PARA_INFO_LOG("%" PRIu32 " seconds, %d frames/chunk\n", afhi->seconds_total, frames_per_chunk); ct_size = 250; - afhi->chunk_table = para_malloc(ct_size * sizeof(uint32_t)); + afhi->chunk_table = arr_alloc(ct_size, sizeof(uint32_t)); afhi->chunk_table[0] = 0; afhi->chunk_table[1] = afhi->header_len; oss.returned = afhi->header_len; @@ -178,9 +179,9 @@ int oac_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, j++; if (j >= ct_size) { ct_size *= 2; - afhi->chunk_table = para_realloc( + afhi->chunk_table = arr_realloc( afhi->chunk_table, - ct_size * sizeof(uint32_t)); + ct_size, sizeof(uint32_t)); } afhi->chunk_table[j] = oss.returned; } @@ -364,9 +365,9 @@ struct oac_custom_header { * * \sa \ref oac_custom_header_init(). */ -struct oac_custom_header *oac_custom_header_new(void) +__malloc struct oac_custom_header *oac_custom_header_new(void) { - return para_calloc(sizeof(struct oac_custom_header)); + return zalloc(sizeof(struct oac_custom_header)); } /**