[vorbis] ov_open_callbacks
Michael Smith
msmith at labyrinth.net.au
Mon Mar 4 20:59:40 PST 2002
At 08:49 PM 3/4/02 -0500, you wrote:
>Hi`
>
>Is there some example code on how to use ov_open_callbacks with VorbisFile?
>The documentation I found is _very_ sparse and if possible I don't want to
>spend much time adding streaming from memory to my code.
There isn't actual documentation of these included, but here's a short
summary (it's simple):
You have four callbacks: seek, read, tell, close
vorbisfile was originally written for (only) files, using C stdio - so
these functions were originally just fseek, fread, ftell, and fclose (with
the single change that we have a 64 bit seek function).
The callbacks are required to implement the same semantics as the C stdio
functions - the one not-completely-obvious one is that you should return
-1 from your seek callback if you don't support seeking (in this case, the
tell callback will never be called, so you needn't implement that either).
You can also make the close callback not do anything if you don't want
vorbisfile to 'close' your underlying stream (which is common for things
like streaming from memory).
If you don't want seeking, you only really need to _do_ anything with the
read callback:
size_t (*read_func)(void *ptr, size_t size, size_t nmemb, void *datasource)
Returns -1 on failure. Otherwise, reads up to size*nmemb bytes into the
buffer at ptr, and returns the number of bytes actually read.
If you do need seeking, then just open up your favourite C reference,
and implement something with stdio semantics. Pretty simple.
Feel free to ask any further questions. I'll try and write up some better
docs on the callbacks some time soon.
Michael
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'vorbis-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the Vorbis
mailing list