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

Monty xiphmont at xiph.org
Wed May 5 16:37:10 PDT 2004



I was about to suggest the same thing, but I see Conrad has beaten me
to it.  In case it wasn't clear from what Conrad said...

Just set up the fake stdio callbacks to pretend that the given section
of your file that is an Ogg archive is the whole file.  So long as the
callbacks act like seek(SEEK_SET,0) is the beginning of the ogg 'file'
 and seek(SEEK_END,0) is the end of the ogg 'file', Vorbisfile will
function as if that Ogg archive in the larger file is a standalone Ogg
file.  make sure the 'read' function doesn't allow reading past the
end either.

Sorry for letting this thread go on so long without this suggestion
coming up, I was on vacation :-|

Monty

<p>On Tue, May 04, 2004 at 03:43:35PM +1000, Conrad Parker wrote:
> Hi Ken,
> 
> by the sounds of it, you're dealing with a bunch of really short sound
> effects, right? and you want to be able to grab one, decode it, and
> send it off to play?
> 
> You want to be using vorbisfile's callback functions, including seek:
> 
>   http://www.xiph.org/ogg/vorbis/doc/vorbisfile/callbacks.html
> 
> Let's say you have a sound effect which you know starts at byte 10000
> and ends at byte 25000.
> 
> You supply fake functions for seek, read and tell which make libvorbisfile
> think that it's actually dealing with a 15000 byte long file; ie. you
> translate seek requests by an offset of 10000 and you make any request
> beyond 15000 look like an EOF.
> 
> You pass these functions to ov_open_callbacks() when you create your
> vorbisfile handle, then you just use libvorbisfile as though you'd just
> opened a single sound effect disk file.
> 
> another guy wrote some SDL_mixer support using liboggz+libfishsound, which
> do similar stuff to libvorbisfile but are callback based (and can handle
> multitrack, but you probably don't need that):
> 
>   http://www.dingoskidneys.com/fishmixer/
> 
> You'd want to check out OggzIO in the oggz api docs if you go down that
> path, but it's the same kind of deal as for vorbisfile: you set up the
> right callbacks, then just let the library do its thing.
> 
> Conrad.
> 
> On Mon, May 03, 2004 at 11:58:23PM -0500, Ken Rogoway wrote:
> > Michael,
> > 
> > I respect your knowledge and apologize if I am trying to do something that
> > is poor application design.  Having coded for over 20 years I would like
> > to think that I should know better, but I am a bit stumped as to how I can
> > have 100+ different OGG files inside a large package file, and then when
> > needed go and grab a single OGG file from the package to decode it for
> > the SDL_mixer which expects a properly decoded wave buffer.  If you have
> > some thoughts on how best to approach this I would greatly appreciate your
> > sharing them with me.
> > 
> > I guess my biggest problem is that I am trying to take two 3rd party
> > libraries
> > and make them work with a pack file scheme.  It sounds like I am being an
> > idiot in my approach.  Please explain a better way to do this.
> > 
> > Sincerely,
> > 
> > - Ken Rogoway
> > 
> > > Okay.  It seems like this could have been solved by having a parm for non-
> > > seekable streams that specified the size of the stream.  Regardless, I
> > > understand
> > > what you are saying and realize the limitations vs. what I am trying to
> > do.
> > 
> > It's very rare to have a non-seekable stream where you know the size of the
> > stream in advance - and it's almost completely useless. Such a parameter
> > would just encourage poor application design.
> > 
> > In your case, the stream IS seekable - it's just that you're lying to
> > libvorbisfile and telling it that it isn't seekable, to simplify your
> > implementation.
> > 
> > This _seems_ useful to you because of limitations in some other part of your
> > program.
> > 
> > 
> > > I want to load the entire steam so I can pass off the decoded data to a
> > > function
> > > that plays wave data.
> > 
> > I suspected so. This is a flaw in your system - you shouldn't have to pass
> > the
> > entire stream all at once. You should seriously consider a different
> > approach
> > where you can decode incrementally and pass smaller buffers to the playback
> > part of your program. This isn't usually hard to do.
> > 
> > Mike
> > 
> > --- >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.672 / Virus Database: 434 - Release Date: 4/28/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.
> --- >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'



More information about the Vorbis-dev mailing list