This function may return -1, and we do not want to use a negative
granule position for the computation of the duration of the ogg file.
Note that oac_get_file_info() loops over all ogg pages twice, but
the second loop does not have the same problem as we already check
the return value there.
/* 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;