[vorbis-dev] Bug in vorbisfile.c?

Michael Smith msmith at labyrinth.net.au
Fri Mar 22 00:41:23 PST 2002



At 06:52 PM 3/21/02 -0800, you wrote:
>I'm using RC1 right now (I think...switching to the new stuff would
>impact my code pretty badly I think, which is why I haven't bothered
>changing over).
>
>Anyway, I'm hitting an infinite loop and I don't know if this is me
>screwing up or a bug in vorbis -- it only happens on my PowerMac (OS X),
>and only when I made some changes recently to the rest of my code base.
>
>The code is in ov_read, where it does this:
>
>if ( samples>length/bytespersample) samples = length/bytespersample;
>
>I call the function with "length" 2.  samples is set to 32, and
>bytespersample is 4 (words*channels=2*2), which evaluates to:
>
>if ( 32 > 0 ) samples = 0;
>
>So samples is set to "0", and thus ov_read will always return 0 with
>that particular input.
>
>Is this a result of me doing something wrong/not understanding how it's
>supposed to work, or is it an actual bug?

I see you've solved your problem, but I thought I'd comment anyway.

You give length=2, but the vorbisfile interfaces is designed to deal
in terms of samples for all channels - that is, one sample means 
(everywhere the term occurs in vorbisfile) one physical sample per
channel. 

The way it is defined, you'll only ever get whole samples for all 
channels returned. Since you're dealing with stereo, this means
there isn't space for 1 sample (4 bytes) in the buffer supplied - so
vorbisfile returns 0. 

It would be possible (and perhaps useful) to return an error code
in this case - the documentation defines a return of 0 from vorbisfile
to mean 'EOF', so this could be considered a bug. OV_EINVAL would make
sense (invalid parameters passed).

Michael

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