[vorbis] Using vorbisfile with an in-memory file instead of FILE*

Michael Smith msmith at labyrinth.net.au
Mon Dec 25 05:05:09 PST 2000



>> Use ov_open_callbacks() and write callbacks which fake reading from a file
>> (while actually reading from memory buffers). vorbisfile is designed for
>> reading from a file, so the interface is a bit messy when you try to do
>> this, but it is possible.
>
>I thought maybe it was possible with the two parameters that specify you've
>already read a bit (in this case the whole file), but that didn't work.
>Is there some documentation of those callbacks?
>I didn't find very much docs about it.

Those should work, but aren't a complete solution. You still need to write
the callbacks (although if you have the ENTIRE file in memory before the
open call, the callbacks can just return appropriate errors).

The callbacks follow the prototypes (more or less - the seek function uses
a 64 bit offset, and they all use void pointers instead of FILE pointers)
for fread, ftell, fseek, and fclose. They also follow the return semantics.
Originally, vorbisfile just used these functions directly - the callbacks
were a later addition. 

If you look at the winamp plugin, it provides a pretty complete example of
what return values to produce under what circumstances (it actually goes to
more effort to produce the exact result than is strictly needed, so as to
serve as a useful example). Basically, just read manpages/documentation for
those functions, and hack something in to do what you want.
Straightforward. If you want to feed everything through the initial buffer,
just have them return the standard error return for that function (0 for
fread(), etc.)

Michael

--- >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