X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=ogg_afh_common.c;h=ad5963ebc1488ca32d6c2055ee5009fd377d4c8c;hp=1deb5cdae194b1bf5b026ffd719d2f316fcba086;hb=f0c195e0ee6baefae0046db0e10df2e45f72ca41;hpb=b62e2796b85c7d7f3138fe729f4637853e0fafe0 diff --git a/ogg_afh_common.c b/ogg_afh_common.c index 1deb5cda..ad5963eb 100644 --- a/ogg_afh_common.c +++ b/ogg_afh_common.c @@ -37,13 +37,16 @@ static int process_packets_2_and_3(ogg_sync_state *oss, * apparent at packetout. */ ogg_stream_pagein(stream, &page); + PARA_INFO_LOG("ogg page serial: %d\n", + ogg_page_serialno(&page)); while (i < 2) { ret = ogg_stream_packetout(stream, &packet); if (ret == 0) break; if (ret < 0) return -E_STREAM_PACKETOUT; - ret = ci->packet_callback(&packet, i + 1, afhi, + ret = ci->packet_callback(&packet, i + 1, + ogg_page_serialno(&page), afhi, ci->private_data); if (ret < 0) return ret; @@ -77,14 +80,13 @@ static int process_ogg_packets(ogg_sync_state *oss, struct afh_info *afhi, ret = -E_STREAM_PACKETOUT; if (ogg_stream_packetout(&stream, &packet) != 1) goto out; - ret = ci->packet_callback(&packet, 0, afhi, ci->private_data); + ret = ci->packet_callback(&packet, 0, ogg_page_serialno(&page), + afhi, ci->private_data); if (ret < 0) goto out; ret = process_packets_2_and_3(oss, &stream, afhi, ci); if (ret < 0) goto out; - afhi->header_offset = 0; - afhi->header_len = oss->returned; ret = 1; out: ogg_stream_clear(&stream); @@ -110,9 +112,9 @@ static void set_chunk_tv(int num_frames, int num_chunks, int frequency, * given by \a map and \a numbytes and passes each packet to the callback * defined by \a ci. * - * If the packet callback indicates success, the chunk table is built. Chunk - * zero contains the first three ogg packets while all other chunks consist of - * exactly one ogg page. + * If the packet callback indicates success and \a afhi is not \p NULL, the + * chunk table is built. Chunk zero contains the first three ogg packets while + * all other chunks consist of exactly one ogg page. * * \param map Audio file data. * \param numbytes The length of \a map. @@ -143,6 +145,9 @@ int ogg_get_file_info(char *map, size_t numbytes, struct afh_info *afhi, ret = process_ogg_packets(&oss, afhi, ci); if (ret < 0) goto out; + if (!afhi) + goto out; + afhi->header_len = oss.returned; oss.returned = 0; oss.fill = numbytes; /* count ogg packages and get duration of the file */