Commit 560daffd authored by conrad's avatar conrad

add oggz_run_set_blocksize() function


git-svn-id: http://svn.annodex.net/liboggz/trunk@2027 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 4eddf3fc
......@@ -476,6 +476,17 @@ OGGZ * oggz_open_stdio (FILE * file, int flags);
*/
int oggz_flush (OGGZ * oggz);
/**
* Set the blocksize to use internally for oggz_run()
* \param oggz An OGGZ handle previously opened for either reading or writing
* \param blocksize The blocksize to use within oggz_run()
* \retval 0 Success
* \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
* \retval OGGZ_ERR_INVALID Invalid blocksize (\a run_blocksize <= 0)
*/
int oggz_run_set_blocksize (OGGZ * oggz, long blocksize);
/**
* Run an OGGZ until completion, or error
* \param oggz An OGGZ handle previously opened for either reading or writing
......
......@@ -16,6 +16,7 @@
oggz_get_bos;
oggz_get_eos;
oggz_run_set_blocksize;
oggz_run;
oggz_set_read_callback;
......
......@@ -88,6 +88,7 @@ oggz_new (int flags)
oggz->offset = 0;
oggz->offset_data_begin = 0;
oggz->run_blocksize = 1024;
oggz->cb_next = 0;
oggz->streams = oggz_vector_new ();
......@@ -246,14 +247,26 @@ oggz_run (OGGZ * oggz)
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
if (OGGZ_CONFIG_WRITE && (oggz->flags & OGGZ_WRITE)) {
while ((n = oggz_write (oggz, 1024)) > 0);
while ((n = oggz_write (oggz, oggz->run_blocksize)) > 0);
} else if (OGGZ_CONFIG_READ) {
while ((n = oggz_read (oggz, 1024)) > 0);
while ((n = oggz_read (oggz, oggz->run_blocksize)) > 0);
}
return n;
}
int
oggz_run_set_blocksize (OGGZ * oggz, long blocksize)
{
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
if (blocksize <= 0) return OGGZ_ERR_INVALID;
oggz->run_blocksize = blocksize;
return 0;
}
/******** oggz_stream management ********/
static int
......
......@@ -198,6 +198,7 @@ struct _OGGZ {
off_t offset; /* offset of current page start */
off_t offset_data_begin; /* offset of unit 0 page start */
long run_blocksize; /* blocksize to use for oggz_run() */
int cb_next;
OggzVector * streams;
......
......@@ -657,6 +657,7 @@ main (int argc, char ** argv)
}
}
oggz_run_set_blocksize (oggz, 1024*1024);
oggz_run (oggz);
oggz_close (oggz);
......
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