Commit 718a73d3 authored by conrad's avatar conrad

oggz_read: always set the internal offset to the start of the current page.

This is returned by oggz_tell() and can be queried within a ReadPage callback.
parent 38b6dffb
......@@ -139,6 +139,7 @@ struct _OggzReader {
ogg_int64_t current_unit;
ogg_int64_t current_granulepos;
long current_page_bytes;
#if 0
oggz_off_t offset_page_end; /* offset of end of current page */
#endif
......
......@@ -86,6 +86,8 @@ oggz_read_init (OGGZ * oggz)
reader->current_unit = 0;
reader->current_page_bytes = 0;
return oggz;
}
......@@ -183,26 +185,33 @@ oggz_read_get_next_page (OGGZ * oggz, ogg_page * og)
oggz_off_t page_offset = 0, ret;
int found = 0;
/* Increment oggz->offset by length of the last page processed */
oggz->offset += reader->current_page_bytes;
do {
more = ogg_sync_pageseek (&reader->ogg_sync, og);
if (more == 0) {
/* No page available */
page_offset = 0;
return -2;
} else if (more < 0) {
#ifdef DEBUG_VERBOSE
printf ("get_next_page: skipped %ld bytes\n", -more);
#endif
page_offset -= more;
page_offset += (-more);
oggz->offset += (-more);
} else {
#ifdef DEBUG_VERBOSE
printf ("get_next_page: page has %ld bytes\n", more);
#endif
reader->current_page_bytes = more;
found = 1;
}
} while (!found);
#if 0 /* This is now done by the increment at the top of the file */
/* Calculate the byte offset of the page which was found */
if (bytes > 0) {
oggz->offset = oggz_io_tell (oggz) - bytes + page_offset;
......@@ -214,6 +223,9 @@ oggz_read_get_next_page (OGGZ * oggz, ogg_page * og)
}
return ret;
#else
return oggz->offset;
#endif
}
typedef struct {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment