[vorbis-dev] Thoughts on vorbisfile

Michael Smith msmith at labyrinth.net.au
Thu Apr 20 22:45:20 PDT 2000



Hi all,

While reading through various bits of libvorbis and vorbisfile, and then
thinking about how to implement other features in the xmms and winamp
plugins, I had some thoughts...

Vorbisfile is very useful, and very easy to use. It is, however, tied to
stdio - which means you can't use it for lots of other stuff where it'd be
useful - like streaming, or (under win32) avoiding stdio and using the
win32 file functions (which might have some advantages). Reimplementing
much of vorbisfile, or copy/pasting it into another program, seems to
rather wasteful, and vorbisfile does everything that a decoder needs.

More than 95% of the vorbisfile code doesn't actually care about the
underlying data source, however. Looking through it, we see a total of 4
functions called:
 fread()
 fseek()
 ftell()
 fclose()

It would seem useful to modify vorbisfile to abstract the functions used
for reading, seeking, and closing a file. 

A seperate version of ov_open() could be available, which would take 3
extra arguments - to function pointers for these functions. We don't really
need ftell() - it is solely used to get the file length, and there are a
couple of ways we could do this - either an extra argument to ov_open(), or
make the seek function return the current file position (these functions
need not map precisely to the stdio equivalents, though they'll be close).

I've played around with this a bit, and have a compiling (but untested)
version that does this - it needs cleaning up a bit first, but I think it's
basically a good idea.

So - what do people think of doing this? It would make vorbisfile much more
useful, at the expense of very little added complexity (and if we retain
the current ov_open() call, none except when the extra functionality is
needed).

If it is agreed that this is worthwhile, I'll clean up what I have, and
send it in for criticism.

Michael

--- >8 ----
List archives:  http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/



More information about the Vorbis-dev mailing list