[vorbis-dev] Problems with vorbisfile

Michael Smith msmith at labyrinth.net.au
Sat Mar 17 23:58:00 PST 2001



>I cut this fragment of code and pasted into my program in place of
>ov_open() call. Unfortunately I couldn't compile it because I didn't have a
>prototype for _fseek64_wrap(). I already knew that seeking caused problems
>and the vorbisfile lib would treat the stream as unseekable if the seek
>function returned -1. I wrote a simple seek functions returning -1 and
>placed it in the callbacks structure. After that the vorbisfile_example
>compiled and run fine, and my version of the code as well. There's
>definitely something wrong with vorbisfile library as Visual C++ users are
>concerned.

Well, other VC++ users don't have any problems with this, so it's 
a problem with your setup specifically, not with libvorbis and MSVC 
in general. There are lots of programs widely used which use libvorbis
and MSVC (winamp and freeamp plugins are both compiled with MSVC, for
example). 

The most common problem with this is linking against the wrong version
of the C runtime - since libvorbis is linked against the multithreaded
dll, your program has to be also (it's pretty stupid that things just
randomly fail otherwise - but they do. Blame microsoft).

>
>I also had some problems with using ov_read() - I pass to this function a
>number of bytes I want it to return (the docs suggest 4096), but it always
>(at least with my ogg/vorbis files) returns 512 or less bytes depending on
>the current packet or something. 

The documentation here is actually slightly inaccurate - nobody has got
around to changing it since the inaccuracy was found. Sorry about that.
ov_read() will actually return up to one fully-decoded vorbis packet, I
believe. (this could be much smaller than it is with your test files, 
though that's not likely - but the format allows it). It's simple to 
have a small loop around it like this:
        bytes_to_read = 4096; /* or whatever */
        while(bytes_to_read>0)
        {	
                ret = ov_read(...,bytes_to_read,...);
                if(ret==0) {
                        break; /* EOS */ 
                }
                else if(ret <0) {
                        /* Hole in data. Notify the rest of the program, but safe
                           to continue */
                        fprintf(stderr, "Hole in data!\n");
                }	
                else bytes_to_read -= ret;
        }

This way, you get to deal with errors on a packet-by-packet basis, but
you've still got simple code to use here, without having to do extra
buffering somewhere.

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-dev-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-dev mailing list