[vorbis] ov_open from memory

Michael Smith
2003-02-27T17:00:47Z

Mike <just.me@aon.at> said:

> Hi folks,
>
> i would like to know if it is valid to load a whole .ogg file into memory
> and call ov_open like this:
> ov_open(NULL, &OggVorbisFile, pRawData, RawDataLen);

This should work, but may not. It's not the preferred way to do this (see
below).

> An other question is, is it valid to copy some ogg files into one
(resource)
> file, position the filehandle and use ov_read to read only the ogg file
> which starts at the current position of the file handle? (In other words,
> does ov_read return 0 only if the end of file is reached or also if the
> current file content has ended?)

This will not work correctly.

>
> As already mentioned, i use one resourcefile which contains all my data.
> Whats the best way to load the ogg files from the resource file?

Ok. It's pretty straightforward - both for the latter case, where this is
neccesary, and for the from-memory case (where it's preferred). Rather than
using ov_open, use ov_open_callbacks, and implement a set of callbacks that
work for your format (where 'format' might be a large memory buffer, or
it
might be a subset of a single file (your resource file).

The callbacks are documented and very straightforward, but if you can't
figure
them out feel free to ask for more specific assisstance here.

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-request@xiph.org'
containing only the word 'unsubscribe' in the body.  No subject is
needed.
Unsubscribe messages sent to the list will be ignored/filtered.