-/*
- * Simple stream reposition routine
- */
-static int ogg_reposition_stream(long unsigned request)
-{
- int ret;
- long seek;
-
- seek = chunk_table[request];
- ret = fseek(infile, seek, SEEK_SET);
- PARA_DEBUG_LOG("seek to %li returned %d. offset:%li\n", seek,
- ret, ftell(infile));
- return ret < 0? -E_OGG_REPOS : 1;
-}
-
-static ogg_int64_t get_chunk_size(long unsigned chunk_num)
-{
- ogg_int64_t ret;
- if (chunk_num >= num_chunks)
- return -1;
- ret = chunk_table[chunk_num + 1] - chunk_table[chunk_num];
- if (!ret)
- return ret;
-#if 0
- PARA_DEBUG_LOG("chunk %d: %lli-%lli (%lli bytes)\n",
- chunk_num,
- chunk_table[chunk_num],
- chunk_table[chunk_num + 1] - 1,
- ret);
-#endif
- return ret;
-}
-
-char *ogg_read_chunk(long unsigned current_chunk, ssize_t *len)
-{
- int ret;
- ogg_int64_t cs = get_chunk_size(current_chunk);
- if (!cs) { /* nothing to send for this run */
- *len = 0;
- return oggbuf;
- }
- if (cs < 0) { /* eof */
- *len = 0;
- return NULL;
- }
- *len = cs;
- if (!oggbuf || oggbuf_len < *len) {
- PARA_INFO_LOG("increasing ogg buffer size (%d -> %zu)\n",
- oggbuf_len, *len);
- oggbuf = para_realloc(oggbuf, *len);
- oggbuf_len = *len;
- }
- ret = read(fileno(infile), oggbuf, *len);
- if (!ret) {
- *len = 0;
- return NULL;
- }
- if (ret < 0) {
- *len = -E_OGG_READ;
- return NULL;
- }
- if (ret != *len)
- PARA_WARNING_LOG("short read (%d/%zd)\n", ret, *len);
- *len = ret;
- return oggbuf;
-}
-
-static char *ogg_get_header_info(int *len)
-{
- *len = header_len;
- return header;
-}
-