Blame doc/vorbisfile/ov_open.html

Packit 06404a
<html>
Packit 06404a
Packit 06404a
<head>
Packit 06404a
<title>Vorbisfile - function - ov_open</title>
Packit 06404a
<link rel=stylesheet href="style.css" type="text/css">
Packit 06404a
</head>
Packit 06404a
Packit 06404a
<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
Packit 06404a
Packit 06404a
Packit 06404a

Vorbisfile documentation

Packit 06404a

vorbisfile version 1.3.2 - 20101101

Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a

ov_open

Packit 06404a
Packit 06404a

declared in "vorbis/vorbisfile.h";

Packit 06404a
Packit 06404a

ov_open is one of three initialization functions used to initialize

Packit 06404a
an OggVorbis_File structure and prepare a bitstream for playback.
Packit 06404a
Packit 06404a

WARNING for Windows developers: Do not use ov_open() in

Packit 06404a
Windows applications; Windows linking places restrictions on
Packit 06404a
passing <tt>FILE *</tt> handles successfully, and ov_open() runs
Packit 06404a
afoul of these restrictions [a].  See the 
Packit 06404a
href="ov_open_callbacks.html">ov_open_callbacks() page  for
Packit 06404a
details on using 
Packit 06404a
href="ov_open_callbacks.html">ov_open_callbacks() instead. 
Packit 06404a
Packit 06404a

The first argument must be a file pointer to an already opened file

Packit 06404a
or pipe (it need not be seekable--though this obviously restricts what
Packit 06404a
can be done with the bitstream). <tt>vf</tt> should be a pointer to the
Packit 06404a
OggVorbis_File structure -- this is used for ALL the externally visible libvorbisfile
Packit 06404a
functions. Once this has been called, the same OggVorbis_File
Packit 06404a
struct should be passed to all the libvorbisfile functions.

Packit 06404a
Packit 06404a
The <tt>vf</tt> structure initialized using ov_fopen() must eventually
Packit 06404a
be cleaned using ov_clear().  Once a
Packit 06404a
<tt>FILE *</tt> handle is passed to ov_open() successfully, the
Packit 06404a
application MUST NOT <tt>fclose()</tt> or in any other way manipulate
Packit 06404a
that file handle.  Vorbisfile will close the file in 
Packit 06404a
href="ov_clear.html">ov_clear().  If the application must be able
Packit 06404a
to close the <tt>FILE *</tt> handle itself, see 
Packit 06404a
href="ov_open_callbacks.html">ov_open_callbacks() with the use of
Packit 06404a
<tt>OV_CALLBACKS_NOCLOSE</tt>.
Packit 06404a
Packit 06404a

It is often useful to call <tt>ov_open()</tt> simply to determine

Packit 06404a
whether a given file is a Vorbis bitstream. If the <tt>ov_open()</tt>
Packit 06404a
call fails, then the file is not recognizable as Vorbis.  If the call
Packit 06404a
succeeds but the initialized <tt>vf</tt> structure will not be used,
Packit 06404a
the application is responsible for calling 
Packit 06404a
href="ov_clear.html">ov_clear() to clear the decoder's buffers and
Packit 06404a
close the file.

Packit 06404a
Packit 06404a
If [and only if] an <tt>ov_open()</tt> call fails, the application
Packit 06404a
must explicitly <tt>fclose()</tt> the <tt>FILE *</tt> pointer itself.
Packit 06404a
Packit 06404a
Packit 06404a


Packit 06404a
Packit 06404a
Packit 06404a
	
Packit 06404a
Packit 06404a
int ov_open(FILE *f,OggVorbis_File *vf,char *initial,long ibytes);
Packit 06404a
Packit 06404a
	
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a

Parameters

Packit 06404a
Packit 06404a
f
Packit 06404a
File pointer to an already opened file
Packit 06404a
or pipe (it need not be seekable--though this obviously restricts what
Packit 06404a
can be done with the bitstream).
Packit 06404a
vf
Packit 06404a
A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile
Packit 06404a
functions. Once this has been called, the same <tt>OggVorbis_File</tt>
Packit 06404a
struct should be passed to all the libvorbisfile functions.
Packit 06404a
initial
Packit 06404a
Typically set to NULL. This parameter is useful if some data has already been
Packit 06404a
read from the file and the stream is not seekable. It is used in conjunction with <tt>ibytes</tt>.  In this case, <tt>initial</tt>
Packit 06404a
should be a pointer to a buffer containing the data read.
Packit 06404a
ibytes
Packit 06404a
Typically set to 0. This parameter is useful if some data has already been
Packit 06404a
read from the file and the stream is not seekable. In this case, <tt>ibytes</tt>
Packit 06404a
should contain the length (in bytes) of the buffer.  Used together with <tt>initial</tt>
Packit 06404a
Packit 06404a
Packit 06404a
Packit 06404a

Return Values

Packit 06404a
Packit 06404a
  • 0 indicates success
  • Packit 06404a
    Packit 06404a
  • less than zero for failure:
  • Packit 06404a
      Packit 06404a
    • OV_EREAD - A read from media returned an error.
    • Packit 06404a
    • OV_ENOTVORBIS - Bitstream is not Vorbis data.
    • Packit 06404a
    • OV_EVERSION - Vorbis version mismatch.
    • Packit 06404a
    • OV_EBADHEADER - Invalid Vorbis bitstream header.
    • Packit 06404a
    • OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.
    • Packit 06404a
      Packit 06404a
      Packit 06404a

      Packit 06404a
      Packit 06404a
      Packit 06404a

      Notes

      Packit 06404a
      Packit 06404a
      Packit 06404a
      Packit 06404a
      [a] Windows and ov_open()

      Packit 06404a
      Packit 06404a
      Under Windows, stdio file access is implemented in each of many
      Packit 06404a
      variants of crt.o, several of which are typically installed on any one
      Packit 06404a
      Windows machine.  If libvorbisfile and the application using
      Packit 06404a
      libvorbisfile are not linked against the exact same
      Packit 06404a
      version/variant/build of crt.o (and they usually won't be, especially
      Packit 06404a
      using a prebuilt libvorbis DLL), <tt>FILE *</tt> handles cannot be
      Packit 06404a
      opened in the application and then passed to vorbisfile to be used
      Packit 06404a
      by stdio calls from vorbisfile's different version of CRT.  For this
      Packit 06404a
      reason, using ov_open() under Windows
      Packit 06404a
      without careful, expert linking will typically cause a protection
      Packit 06404a
      fault.  Windows programmers should use 
      Packit 06404a
      href="ov_fopen.html">ov_fopen() (which will only use libvorbis's
      Packit 06404a
      crt.o) or ov_open_callbacks()
      Packit 06404a
      (which will only use the application's crt.o) instead.

      Packit 06404a
      Packit 06404a
      This warning only applies to Windows and only applies to 
      Packit 06404a
      href="ov_open.html">ov_open().  It is perfectly safe to use 
      Packit 06404a
      href="ov_open.html">ov_open() on all other platforms.

      Packit 06404a
      Packit 06404a
      For more information, see the following microsoft pages on 
      Packit 06404a
      href="http://msdn2.microsoft.com/en-us/library/abx4dbyh(VS.80).aspx">C
      Packit 06404a
      runtime library linking and a specific description of 
      Packit 06404a
      href="http://msdn2.microsoft.com/en-us/library/ms235460(VS.80).aspx">restrictions
      Packit 06404a
      on passing CRT objects across DLL boundaries.
      Packit 06404a
      Packit 06404a

      Packit 06404a
      Packit 06404a
      [b] Threaded decode

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

      Packit 06404a
      Packit 06404a
      [c] Mixed media streams

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

      Packit 06404a
      Packit 06404a
      [d] Faster testing for Vorbis files

      Packit 06404a
      ov_test() and
      Packit 06404a
      href="ov_test_callbacks.html">ov_test_callbacks() provide less
      Packit 06404a
      computationally expensive ways to test a file for Vorbisness, but
      Packit 06404a
      require more setup code.

      Packit 06404a
      Packit 06404a
      Packit 06404a
      Packit 06404a


      Packit 06404a

      Packit 06404a
      Packit 06404a
      Packit 06404a

      copyright © 2000-2010 Xiph.Org

      Packit 06404a

      Ogg Vorbis

      Packit 06404a
      Packit 06404a

      Vorbisfile documentation

      Packit 06404a

      vorbisfile version 1.3.2 - 20101101

      Packit 06404a
      Packit 06404a
      Packit 06404a
      Packit 06404a
      </body>
      Packit 06404a
      Packit 06404a
      </html>