Commit c33909cb authored by conrad's avatar conrad

added query of oggz_io to get input length for seeking

+ fixed 'if (bytes = ERR_BLAH)' typo from friday :)


git-svn-id: http://svn.annodex.net/liboggz/trunk@396 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent f349ad3d
...@@ -69,5 +69,6 @@ install-data-local: doxygen-build.stamp ...@@ -69,5 +69,6 @@ install-data-local: doxygen-build.stamp
uninstall-local: uninstall-local:
rm -rf $(docdir) rm -rf $(docdir)
maintainer-clean-local: clean-local:
if test -d liboggz; then rm -rf liboggz; fi if test -d liboggz; then rm -rf liboggz; fi
if test -f doxygen-build.stamp; then rm -f doxygen-build.stamp; fi
...@@ -205,7 +205,6 @@ static int ...@@ -205,7 +205,6 @@ static int
oggz_read_sync (OGGZ * oggz) oggz_read_sync (OGGZ * oggz)
{ {
OggzReader * reader = &oggz->x.reader; OggzReader * reader = &oggz->x.reader;
long nread = 0;
oggz_stream_t * stream; oggz_stream_t * stream;
ogg_stream_state * os; ogg_stream_state * os;
...@@ -455,12 +454,10 @@ oggz_seek_raw (OGGZ * oggz, oggz_off_t offset, int whence) ...@@ -455,12 +454,10 @@ oggz_seek_raw (OGGZ * oggz, oggz_off_t offset, int whence)
return -1; return -1;
} }
offset_at = oggz_io_tell (oggz); offset_at = oggz_io_tell (oggz);
oggz->offset = offset_at; oggz->offset = offset_at;
ogg_sync_reset (&reader->ogg_sync); ogg_sync_reset (&reader->ogg_sync);
return offset_at; return offset_at;
...@@ -515,8 +512,6 @@ oggz_reset (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence) ...@@ -515,8 +512,6 @@ oggz_reset (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence)
int int
oggz_purge (OGGZ * oggz) oggz_purge (OGGZ * oggz)
{ {
long reset_ret;
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ; if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
if (oggz->flags & OGGZ_WRITE) { if (oggz->flags & OGGZ_WRITE) {
...@@ -559,7 +554,7 @@ oggz_get_next_page (OGGZ * oggz, ogg_page * og) ...@@ -559,7 +554,7 @@ oggz_get_next_page (OGGZ * oggz, ogg_page * og)
if ((bytes = (long) oggz_io_read (oggz, buffer, CHUNKSIZE)) == 0) { if ((bytes = (long) oggz_io_read (oggz, buffer, CHUNKSIZE)) == 0) {
/* schyeah! */ /* schyeah! */
} }
if (bytes = OGGZ_ERR_SYSTEM) { if (bytes == OGGZ_ERR_SYSTEM) {
/*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/ /*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/
return -1; return -1;
} }
...@@ -800,7 +795,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) ...@@ -800,7 +795,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
int fd; int fd;
struct stat statbuf; struct stat statbuf;
oggz_off_t offset_orig, offset_at, offset_guess; oggz_off_t offset_orig, offset_at, offset_guess;
oggz_off_t offset_begin, offset_end, offset_next; oggz_off_t offset_begin, offset_end = -1, offset_next;
ogg_int64_t granule_at; ogg_int64_t granule_at;
ogg_int64_t unit_at, unit_begin = 0, unit_end = -1; ogg_int64_t unit_at, unit_begin = 0, unit_end = -1;
long serialno; long serialno;
...@@ -827,34 +822,31 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) ...@@ -827,34 +822,31 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
return -1; return -1;
} }
#if 0
#ifndef WIN32
if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) {
offset_end = statbuf.st_size;
} else {
/*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/
return -1;
}
#else
if (statbuf.st_mode & S_IFREG) {
offset_end = statbuf.st_size;
} else {
/*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/
return -1;
}
#endif
#else
if (oggz_stat_regular (statbuf.st_mode)) { if (oggz_stat_regular (statbuf.st_mode)) {
offset_end = statbuf.st_size; offset_end = statbuf.st_size;
} else { } else {
/*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/ /*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/
return -1;
/* XXX: should be able to just carry on and guess, as per io */
/*return -1;*/
} }
#endif
} else { } else {
if (oggz->io == NULL || oggz->io->seek == NULL) oggz_off_t offset_save;
if (oggz->io == NULL || oggz->io->seek == NULL) {
/* No file, and no io seek method */ /* No file, and no io seek method */
return -1; return -1;
}
/* Get the offset of the end by querying the io seek method */
offset_save = oggz_io_tell (oggz);
if (oggz_io_seek (oggz, 0, SEEK_END) == -1) {
return -1;
}
offset_end = oggz_io_tell (oggz);
if (oggz_io_seek (oggz, offset_save, SEEK_SET) == -1) {
return -1; /* fubar */
}
} }
if (unit_target == reader->current_unit) { if (unit_target == reader->current_unit) {
...@@ -993,8 +985,6 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target) ...@@ -993,8 +985,6 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
} else { } else {
break; break;
} }
} }
found: found:
......
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