This is an alternative function used to open and initialize an
Chris@1: OggVorbis_File structure when using a data source other than a file,
Chris@1: when its necessary to modify default file access behavior, or to
Chris@1: initialize a Vorbis decode from a FILE * pointer under
Chris@1: Windows where ov_open() cannot be used. It
Chris@1: allows the application to specify custom file manipulation routines
Chris@1: and sets up all the related decoding structures.
Chris@1:
Chris@1:
Once ov_open_callbacks() has been called, the same
Chris@1: OggVorbis_File struct should be passed to all the
Chris@1: libvorbisfile functions. Unlike ov_fopen() and ov_open(), ov_open_callbacks() may be used to
Chris@1: instruct vorbisfile to either automatically close or not to close the
Chris@1: file/data access handle in ov_clear().
Chris@1: Automatic closure is disabled by passing NULL as the close callback,
Chris@1: or using one of the predefined callback sets that specify a NULL close
Chris@1: callback. The application is responsible for closing a file when a
Chris@1: call to ov_open_callbacks() is unsuccessful.
Chris@1:
Chris@1: See also Callbacks and Non-stdio I/O for
Chris@1: information on designing and specifying custom callback functions.
Chris@1:
Chris@1:
Chris@1:
Chris@1:
Chris@1:
Chris@1:
Chris@1: int ov_open_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
Chris@1:
Chris@1:
Chris@1:
Chris@1:
Chris@1:
Chris@1:
Parameters
Chris@1:
Chris@1:
datasource
Chris@1:
Pointer to a data structure allocated by the calling application, containing any state needed by the callbacks provided.
Chris@1:
vf
Chris@1:
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile
Chris@1: functions. Once this has been called, the same OggVorbis_File
Chris@1: struct should be passed to all the libvorbisfile functions.
Chris@1:
initial
Chris@1:
Typically set to NULL. This parameter is useful if some data has already been
Chris@1: read from the stream and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial
Chris@1: should be a pointer to a buffer containing the data read.
Chris@1:
ibytes
Chris@1:
Typically set to 0. This parameter is useful if some data has already been
Chris@1: read from the stream and the stream is not seekable. In this case, ibytes
Chris@1: should contain the length (in bytes) of the buffer. Used together with initial.
Chris@1:
callbacks
Chris@1:
A completed ov_callbacks struct which indicates desired custom file manipulation routines. vorbisfile.h defines several preprovided callback sets; see ov_callbacks for details.
Chris@1:
Chris@1:
Chris@1:
Chris@1:
Return Values
Chris@1:
Chris@1:
0 for success
Chris@1:
less than zero for failure:
Chris@1:
Chris@1:
OV_EREAD - A read from media returned an error.
Chris@1:
OV_ENOTVORBIS - Bitstream does not contain any Vorbis data.
Chris@1:
OV_EVERSION - Vorbis version mismatch.
Chris@1:
OV_EBADHEADER - Invalid Vorbis bitstream header.
Chris@1:
OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
Chris@1:
Chris@1: ... provides exactly the same functionality as ov_open() but will always work correctly under
Chris@1: Windows, regardless of linking setup details.
Chris@1:
Chris@1:
[b] Threaded decode
Chris@1:
If your decoder is threaded, it is recommended that you NOT call
Chris@1: ov_open_callbacks()
Chris@1: in the main control thread--instead, call ov_open_callbacks() in your decode/playback
Chris@1: thread. This is important because ov_open_callbacks() may be a fairly time-consuming
Chris@1: call, given that the full structure of the file is determined at this point,
Chris@1: which may require reading large parts of the file under certain circumstances
Chris@1: (determining all the logical bitstreams in one physical bitstream, for
Chris@1: example). See Thread Safety for other information on using libvorbisfile with threads.
Chris@1:
Chris@1:
Chris@1:
[c] Mixed media streams
Chris@1:
Chris@1: As of Vorbisfile release 1.2.0, Vorbisfile is able to access the
Chris@1: Vorbis content in mixed-media Ogg streams, not just Vorbis-only
Chris@1: streams. For example, Vorbisfile may be used to open and access the
Chris@1: audio from an Ogg stream consisting of Theora video and Vorbis audio.
Chris@1: Vorbisfile 1.2.0 decodes the first logical audio stream of each
Chris@1: physical stream section.
Chris@1:
Chris@1:
[d] Faster testing for Vorbis files
Chris@1:
ov_test() and ov_test_callbacks() provide less
Chris@1: computationally expensive ways to test a file for Vorbisness, but
Chris@1: require more setup code.