[vorbis-dev] Reading OGG embedded in a pack file

Ken Rogoway Ken at Rogoway.com
Mon May 3 20:29:11 PDT 2004



I was able to get most of my OGG files to load from a pack file by doing
what you suggested.  However some of them fail when the stream is not
seekable in the call to:

ov_pcm_total()

This returns a -131 when I set the callbacks.seek_func to return -1 and set
the callbacks.tell_func function to NULL.

This appears to be returning OV_EINVAL (-131) because the stream is not
seekable.  However, my code needs to know the number of samples so I can
allocate a buffer to read into:

    OggVorbis_File vf;
    vorbis_info *info;

    // [snip] some init code was here.

    info = ov_info(&vf, -1);

    // This returns -131 when the file is not seekable
    // so how do I determine the number of samples?
    samples = (long)ov_pcm_total(&vf, -1);

    samples * info->channels * 2;
    sndBuffer = malloc(samples * info->channels * 2);

Thanks,

- Ken

-----Original Message-----
From: owner-vorbis-dev at xiph.org [mailto:owner-vorbis-dev at xiph.org]On
Behalf Of Ralph Giles
Sent: Saturday, April 17, 2004 12:04 PM
To: vorbis-dev at xiph.org
Subject: Re: [vorbis-dev] Reading OGG embedded in a pack file

<p>On Sat, Apr 17, 2004 at 11:23:46AM -0500, Ken Rogoway wrote:

> After looking at the documentation I thought I could change the 4th
parameter to be the offset into the stream for where my sub file (inside the
pack file) is located.  This did not work.  It took about 10 seconds for the
function to return so I am guessing it was seeking to the beginning of the
stream and then scanning forward looking for the OGG headers.

No, the 3rd and 4th parameters are to let you provide a 'prefix buffer'
in cases where the underlying file isn't seekable, but you've already
read some of it to do filetype identification. Thus you can pass the bit
you've read so vorbisfile can parse it, and then continue with the
actual stream from the read position.

Thus, your hypotheses is likely correct about what it's doing.

> There are comments about using streams that are not "seekable" and I
thought this also might be a solution, but I could find nothing on how to
tell Vorbis that a stream was not seekable.  Is it as simple as setting the
callbacks.seek_func and callbacks.tell_func to NULL?

You can set tell_func to NULL when the stream is not seekable. You must
always provide a seek_func; the way you mark a stream as not seekable is
by having that function always return (-1) for failure, regardless of
the input. See http://xiph.org/ogg/vorbis/doc/vorbisfile/callbacks.html

Another general solution of course is to doctor your read, seek, and
tell callbacks to operate relative to the offset of the ogg data in
your pak file.

Hope that helps,
 -r
--- >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.


---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.658 / Virus Database: 421 - Release Date: 4/9/2004

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.672 / Virus Database: 434 - Release Date: 4/28/2004

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