[vorbis-dev] vorbisfile updates, and a couple of questions
Michael Smith
msmith at labyrinth.net.au
Fri Apr 21 03:35:18 PDT 2000
The changes to vorbisfile that I suggested earlier have now been committed -
this is mostly a merge of my code with a similar patch from Martin Vogt
(thanks Martin).
The old ov_open() interface remains untouched - and for many people, this is
all you'll need to use, ever. It now calls the new interface with
appropriate arguments.
The new ov_open_callbacks() function adds an extra argument to ov_open() - a
struct of callback functions, which basically follow the stdio functions.
They do have one difference, however - the FILE * arguments have been changed
to void *, so that the user can pass arbitrary data to the functions. This
allows easy use of non-stdio-based vorbisfile. Yay!
If you want to use this new functionality: look at the ov_callbacks struct
in vorbisfile.h, then create appropriate functions, and continue...
The functions you write should follow their stdio counterparts in terms of
return values as closely as possible. Most importantly, seek_func() MUST
return -1 if the stream is unseekable. In this case, tell_func() isn't going to be
used, but be consistent and implement it - it might get used in the future.
If you can't give a result, return -1 from this too.
When I get around to it, I'll convert the winamp plugin over to use normal
windows functions instead of stdio, mostly as an example of how to use the new
interface. If anyone has any questions before I get to this, please DO ask.
Martin - I also applied the kmpg patch you sent to Monty, but I had to
change some things to match the modified vorbisfile interface - please check that
it works and send me another patch if it's broken.
Additionally, I added appropriate c++ incantations to the header files, so
that you can use vorbisfile from c++ (thanks to Martin for this, too).
Now, onto the questions:
Firstly, I've seen xmms lock up under the following circumstances: play
track, wait until it's right near the end (<< 1 second remaining), then try and
seek. All of xmms locks hard.
It looks like either vorbis_ip.output->flush() or ov_time_seek() aren't
returning, but I haven't looked further yet. If anyone else can confirm this,
and/or has a fix, let me know.
Secondly, ov_open() now uses the new interface internally. It creates a
struct consisting of fread, fseek, fclose, and ftell, then passes that
appropriately. This all works fine, but the compiler complains, because the
ov_callbacks functions take a void * in the place of the FILE *. Since they're otherwise
identical, this works - but I can't figure out how to cast the arguments
appropriately so as to shut the compiler up. Casting function pointers appears
to be a rather arcane sort of thing to do. Anyone with more C clues than I
care to speak up?
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