cannam@86: cannam@86: cannam@86: cannam@86: Vorbisfile - function - ov_open_callbacks cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86:

Vorbisfile documentation

vorbisfile version 1.3.2 - 20101101

cannam@86: cannam@86:

ov_open_callbacks

cannam@86: cannam@86:

declared in "vorbis/vorbisfile.h";

cannam@86: cannam@86:

This is an alternative function used to open and initialize an cannam@86: OggVorbis_File structure when using a data source other than a file, cannam@86: when its necessary to modify default file access behavior, or to cannam@86: initialize a Vorbis decode from a FILE * pointer under cannam@86: Windows where ov_open() cannot be used. It cannam@86: allows the application to specify custom file manipulation routines cannam@86: and sets up all the related decoding structures. cannam@86: cannam@86:

Once ov_open_callbacks() has been called, the same cannam@86: OggVorbis_File struct should be passed to all the cannam@86: libvorbisfile functions. Unlike ov_fopen() and ov_open(), ov_open_callbacks() may be used to cannam@86: instruct vorbisfile to either automatically close or not to close the cannam@86: file/data access handle in ov_clear(). cannam@86: Automatic closure is disabled by passing NULL as the close callback, cannam@86: or using one of the predefined callback sets that specify a NULL close cannam@86: callback. The application is responsible for closing a file when a cannam@86: call to ov_open_callbacks() is unsuccessful.

cannam@86: cannam@86: See also Callbacks and Non-stdio I/O for cannam@86: information on designing and specifying custom callback functions.

cannam@86: cannam@86:

cannam@86: cannam@86: cannam@86: cannam@86: cannam@86:
cannam@86:

cannam@86: int ov_open_callbacks(void *datasource, OggVorbis_File *vf, char *initial, long ibytes, ov_callbacks callbacks);
cannam@86: 
cannam@86:
cannam@86: cannam@86:

Parameters

cannam@86:
cannam@86:
datasource
cannam@86:
Pointer to a data structure allocated by the calling application, containing any state needed by the callbacks provided.
cannam@86:
vf
cannam@86:
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile cannam@86: functions. Once this has been called, the same OggVorbis_File cannam@86: struct should be passed to all the libvorbisfile functions.
cannam@86:
initial
cannam@86:
Typically set to NULL. This parameter is useful if some data has already been cannam@86: read from the stream and the stream is not seekable. It is used in conjunction with ibytes. In this case, initial cannam@86: should be a pointer to a buffer containing the data read.
cannam@86:
ibytes
cannam@86:
Typically set to 0. This parameter is useful if some data has already been cannam@86: read from the stream and the stream is not seekable. In this case, ibytes cannam@86: should contain the length (in bytes) of the buffer. Used together with initial.
cannam@86:
callbacks
cannam@86:
A completed ov_callbacks struct which indicates desired custom file manipulation routines. vorbisfile.h defines several preprovided callback sets; see ov_callbacks for details.
cannam@86:
cannam@86: cannam@86: cannam@86:

Return Values

cannam@86:
cannam@86:
  • 0 for success
  • cannam@86:
  • less than zero for failure:
  • cannam@86: cannam@86:
    cannam@86:

    cannam@86: cannam@86:

    Notes

    cannam@86:
    cannam@86: cannam@86:
    [a] Windows and use as an ov_open() substitute

    Windows cannam@86: applications should not use ov_open() due cannam@86: to the likelihood of CRT linking cannam@86: mismatches and runtime protection faults cannam@86: [ov_open:a]. ov_open_callbacks() is a safe substitute; specifically: cannam@86: cannam@86:

    ov_open_callbacks(f, vf, initial, ibytes, OV_CALLBACKS_DEFAULT);
    cannam@86: 
    cannam@86: cannam@86: ... provides exactly the same functionality as ov_open() but will always work correctly under cannam@86: Windows, regardless of linking setup details.

    cannam@86: cannam@86:

    [b] Threaded decode

    cannam@86:

    If your decoder is threaded, it is recommended that you NOT call cannam@86: ov_open_callbacks() cannam@86: in the main control thread--instead, call ov_open_callbacks() in your decode/playback cannam@86: thread. This is important because ov_open_callbacks() may be a fairly time-consuming cannam@86: call, given that the full structure of the file is determined at this point, cannam@86: which may require reading large parts of the file under certain circumstances cannam@86: (determining all the logical bitstreams in one physical bitstream, for cannam@86: example). See Thread Safety for other information on using libvorbisfile with threads. cannam@86:

    cannam@86: cannam@86:

    [c] Mixed media streams

    cannam@86:

    cannam@86: As of Vorbisfile release 1.2.0, Vorbisfile is able to access the cannam@86: Vorbis content in mixed-media Ogg streams, not just Vorbis-only cannam@86: streams. For example, Vorbisfile may be used to open and access the cannam@86: audio from an Ogg stream consisting of Theora video and Vorbis audio. cannam@86: Vorbisfile 1.2.0 decodes the first logical audio stream of each cannam@86: physical stream section.

    cannam@86: cannam@86:

    [d] Faster testing for Vorbis files

    cannam@86:

    ov_test() and ov_test_callbacks() provide less cannam@86: computationally expensive ways to test a file for Vorbisness, but cannam@86: require more setup code.

    cannam@86: cannam@86:

    cannam@86: cannam@86:

    cannam@86:
    cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86: cannam@86:

    copyright © 2000-2010 Xiph.Org

    Ogg Vorbis

    Vorbisfile documentation

    vorbisfile version 1.3.2 - 20101101

    cannam@86: cannam@86: cannam@86: cannam@86: