-typedef struct
-{
- unsigned char *buffer;
- ogg_int64_t ind, buffsize;
-} ov_decode_t;
-
-
-static size_t ovcb_read (void *ptr, size_t size, size_t nb, void *datasource)
-{
- ov_decode_t *ov_decode = (ov_decode_t*)datasource;
- size_t remain, len;
-
- remain = ov_decode->buffsize - ov_decode->ind;
- len = size * nb;
- if (remain < len)
- len = remain - remain % size;
-
- memcpy (ptr, ov_decode->buffer + ov_decode->ind, len);
- ov_decode->ind += len;
-
- return len / size;
-}
-
-static int ovcb_seek (void *datasource, ogg_int64_t offset, int whence)
-{
- ov_decode_t *ov_decode = (ov_decode_t*)datasource;
-
- switch (whence)
- {
- case SEEK_SET:
- break;
- case SEEK_CUR:
- offset += ov_decode->ind;
- break;
- case SEEK_END:
- offset += ov_decode->buffsize;
- break;
- default:
- return -1;
- }
- if (offset < 0 || offset > ov_decode->buffsize)
- return -1;
-
- ov_decode->ind = offset;
- return 0;
-}
-
-static int ovcb_close (void *ov_decode)
-{
- return 0;
-}
-
-static long ovcb_tell (void *ov_decode)
-{
- return ((ov_decode_t*)ov_decode)->ind;
-}
-