I have a number of assets packed into a single file. Some of these are OGG files. I have code to seek to the start of an embedded file, but cannot find any OGG functions that let me start at an arbitary point in a stream. The original code (which works) that opens a stream, then reads in the OGG data starts like this: // Read from an already open stream. // Assumes stream is positioned to start of OGG data // Not a complete function, just enought to show what I am trying to do void readFromPackfile( FILE * pStream ) { OggVorbis_File vf; ov_callbacks callbacks; vorbis_info *info; callbacks.read_func = sdl_read_func; callbacks.seek_func = sdl_seek_func; // Will setting this to NULL let me read from the middle of a stream? callbacks.tell_func = sdl_tell_func; callbacks.close_func = sdl_close_func; if ( ov_open_callbacks( pStream, &vf, NULL, 0, callbacks)==0 ) { // Valid OGG data, so do some code here to read it in... // Get our OGG info info = ov_info( &vf, -1 ); } } 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. 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? Does anyone have any experience reading OGG data from a already open stream which may have non-OGG data in it? Thanks, - Ken <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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.
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@xiph.org' containing only the word 'unsubscribe' in the body. No subject is needed. Unsubscribe messages sent to the list will be ignored/filtered.