Commit b2d47599 authored by conrad's avatar conrad

rolled back status stuff, merged check for all metrics back in


git-svn-id: http://svn.annodex.net/liboggz/trunk@391 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent c6bca30f
......@@ -100,8 +100,6 @@ oggz_new (int flags)
oggz_read_init (oggz);
}
oggz->status = OGGZ_STATUS_INITIALIZED;
return oggz;
}
......
......@@ -166,8 +166,6 @@ struct _OggzIO {
struct _OGGZ {
int flags;
enum OggzStatus status;
FILE * file;
OggzIO * io;
......
......@@ -203,6 +203,7 @@ static int
oggz_read_sync (OGGZ * oggz)
{
OggzReader * reader = &oggz->x.reader;
long nread = 0;
oggz_stream_t * stream;
ogg_stream_state * os;
......@@ -214,19 +215,17 @@ oggz_read_sync (OGGZ * oggz)
int cb_ret = 0;
oggz->status = OGGZ_STATUS_READ_ACTIVE;
/*os = &reader->ogg_stream;*/
op = &packet;
/* handle one packet. Try to fetch it from current stream state */
/* extract packets from page */
while(cb_ret == OGGZ_CONTINUE) {
while(cb_ret == 0){
if (reader->current_serialno != -1) {
/* process a packet if we can. If the machine isn't loaded,
neither is a page */
while(cb_ret == OGGZ_CONTINUE) {
while(cb_ret == 0) {
ogg_int64_t granulepos;
int result;
......@@ -238,7 +237,6 @@ oggz_read_sync (OGGZ * oggz)
/* new stream ... check bos etc. */
if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
/* error -- could not add stream */
oggz->status = OGGZ_STATUS_INTERNAL_ERROR;
return -7;
}
}
......@@ -248,7 +246,6 @@ oggz_read_sync (OGGZ * oggz)
if(result == -1) {
/* hole in the data. */
oggz->status = OGGZ_STATUS_INTERNAL_ERROR;
return -7;
}
......@@ -278,12 +275,11 @@ oggz_read_sync (OGGZ * oggz)
}
}
if (cb_ret == OGGZ_CONTINUE) {
if(oggz_get_next_page_7 (oggz, &og) < 0) {
if (reader->current_unit != 0)
oggz->status = OGGZ_STATUS_READ_EOF;
/* If we've got a stop already, don't read more data in */
if (cb_ret != 0) return cb_ret;
if(oggz_get_next_page_7 (oggz, &og) < 0)
return -404; /* eof. leave unitialized */
}
serialno = ogg_page_serialno (&og);
reader->current_serialno = serialno; /* XXX: maybe not necessary */
......@@ -294,7 +290,6 @@ oggz_read_sync (OGGZ * oggz)
/* new stream ... check bos etc. */
if ((stream = oggz_add_stream (oggz, serialno)) == NULL) {
/* error -- could not add stream */
oggz->status = OGGZ_STATUS_INTERNAL_ERROR;
return -7;
}
}
......@@ -329,15 +324,6 @@ oggz_read_sync (OGGZ * oggz)
ogg_stream_pagein(os, &og);
}
if (cb_ret == OGGZ_CONTINUE) {
oggz->status = OGGZ_STATUS_READ_ACTIVE;
} else if (cb_ret == OGGZ_STOP_ERR) {
oggz->status = OGGZ_STATUS_READ_STOP_ERR;
} else {
oggz->status = OGGZ_STATUS_READ_STOP_OK;
}
}
return cb_ret;
}
......@@ -359,16 +345,18 @@ oggz_read (OGGZ * oggz, long n)
cb_ret = oggz_read_sync (oggz);
while (oggz->status == OGGZ_STATUS_READ_ACTIVE &&
bytes_read > 0 && remaining > 0) {
/* If there's nothing to read yet, don't flag an error */
if (reader->current_unit == 0 && cb_ret == -404) cb_ret = 0;
while (cb_ret != -1 && cb_ret != 1 && bytes_read > 0 && remaining > 0) {
bytes = MIN (remaining, 4096);
buffer = ogg_sync_buffer (&reader->ogg_sync, bytes);
if ((bytes_read = (long) oggz_io_read (oggz, buffer, bytes)) == 0) {
/* schyeah! */
}
if (bytes_read == OGGZ_ERR_SYSTEM) {
if (ferror (oggz->file)) {
return OGGZ_ERR_SYSTEM;
}
}
ogg_sync_wrote (&reader->ogg_sync, bytes_read);
......@@ -378,8 +366,7 @@ oggz_read (OGGZ * oggz, long n)
cb_ret = oggz_read_sync (oggz);
}
if (oggz->status == OGGZ_STATUS_READ_STOP_ERR)
oggz_purge (oggz);
if (cb_ret == -1) oggz_purge (oggz);
return nread;
}
......@@ -391,6 +378,7 @@ oggz_read_input (OGGZ * oggz, unsigned char * buf, long n)
OggzReader * reader;
char * buffer;
long bytes, remaining = n, nread = 0;
int cb_ret = 0;
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
......@@ -400,10 +388,12 @@ oggz_read_input (OGGZ * oggz, unsigned char * buf, long n)
reader = &oggz->x.reader;
oggz_read_sync (oggz);
cb_ret = oggz_read_sync (oggz);
/* If there's nothing to read yet, don't flag an error */
if (reader->current_unit == 0 && cb_ret == -404) cb_ret = 0;
while (oggz->status == OGGZ_STATUS_READ_ACTIVE && /* !oggz->eos && */
remaining > 0) {
while (cb_ret != -1 && cb_ret != 1 && /* !oggz->eos && */ remaining > 0) {
bytes = MIN (remaining, 4096);
buffer = ogg_sync_buffer (&reader->ogg_sync, bytes);
memcpy (buffer, buf, bytes);
......@@ -413,11 +403,10 @@ oggz_read_input (OGGZ * oggz, unsigned char * buf, long n)
remaining -= bytes;
nread += bytes;
oggz_read_sync (oggz);
cb_ret = oggz_read_sync (oggz);
}
if (oggz->status == OGGZ_STATUS_READ_STOP_ERR)
oggz_purge (oggz);
if (cb_ret == -1) oggz_purge (oggz);
return nread;
}
......@@ -522,6 +511,8 @@ oggz_reset (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence)
int
oggz_purge (OGGZ * oggz)
{
long reset_ret;
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
if (oggz->flags & OGGZ_WRITE) {
......
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