<html>
<head>
<title>Vorbisfile - Setup/Teardown</title>
<link rel=stylesheet href="style.css" type="text/css">
</head>
<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
<table border=0 width=100%>
<tr>
<td><p class=tiny>Vorbisfile documentation</p></td>
<td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
</tr>
</table>
<H1>Setup/Teardown</h1> <p>In order to decode audio using
libvorbisfile, a bitstream containing Vorbis audio must be properly
initialized before decoding and cleared when decoding is finished.
The simplest possible case is to use <a
href="ov_fopen.html">ov_fopen()</a> to open the file for access, check
it for Vorbis content, and prepare it for playback. A successful <a
href="return.html">return code</a> from <a
href="ov_fopen.html">ov_fopen()</a> indicates the file is ready for use.
Once the file is no longer needed, <a
href="ov_clear.html">ov_clear()</a> is used to close the file and
deallocate decoding resources.<p>
On systems other than Windows<a href="ov_open.html#winfoot">[a]</a>, an
application may also open a file itself using <tt>fopen()</tt>, then pass the
<tt>FILE *</tt> to libvorbisfile using <a
href="ov_open.html">ov_open()</a>. </b>Do not</b> call
<tt>fclose()</tt> on a file handle successfully submitted to <a
href="ov_open.html">ov_open()</a>; libvorbisfile does this in the <a
href="ov_clear.html">ov_clear()</a> call.<p>
An application that requires more setup flexibility may open a data
stream using <a href="ov_open_callbacks.html">ov_open_callbacks()</a>
to change default libvorbis behavior or specify non-stdio data access
mechanisms.<p>
<p>
All libvorbisfile initialization and deallocation routines are declared in "vorbis/vorbisfile.h".
<p>
<table border=1 color=black width=50% cellspacing=0 cellpadding=7>
<tr bgcolor=#cccccc>
<td><b>function</b></td>
<td><b>purpose</b></td>
</tr>
<tr valign=top>
<td><a href="ov_fopen.html">ov_fopen</a></td>
<td>Opens a file and initializes the Ogg Vorbis bitstream with default values. This must be called before other functions in the library may be
used.</td>
</tr>
<tr valign=top>
<td><a href="ov_open.html">ov_open</a></td>
<td>Initializes the Ogg Vorbis bitstream with default values from a passed in file handle. This must be called before other functions in the library may be
used. <a href="#winfoot"><em>Do not use this call under Windows [a];</em></a> Use <a href="ov_fopen.html">ov_fopen()</a> or <a href="ov_open_callbacks.html">ov_open_callbacks()</a> instead.</td>
</tr>
<tr valign=top>
<td><a href="ov_open_callbacks.html">ov_open_callbacks</a></td>
<td>Initializes the Ogg Vorbis bitstream from a file handle and custom file/bitstream manipulation routines. Used instead of <a href="ov_open.html">ov_open()</a> or <a href="ov_fopen.html">ov_fopen()</a> when altering or replacing libvorbis's default stdio I/O behavior, or when a bitstream must be initialized from a <tt>FILE *</tt> under Windows.</td>
</tr>
<tr valign=top>
<td><a href="ov_test.html">ov_test</a></td>
<td>Partially opens a file just far enough to determine if the file
is an Ogg Vorbis file or not. A successful return indicates that the
file appears to be an Ogg Vorbis file, but the <a
href="OggVorbis_File.html">OggVorbis_File</a> struct is not yet fully
initialized for actual decoding. After a <a href="return.html">successful return</a>, the file
may be closed using <a href="ov_clear.html">ov_clear()</a> or fully
opened for decoding using <a
href="ov_test_open.html">ov_test_open()</a>.<p> This call is intended to
be used as a less expensive file open test than a full <a
href="ov_open.html">ov_open()</a>.<p>
Note that libvorbisfile owns the passed in file resource is it returns success; do not <tt>fclose()</tt> files owned by libvorbisfile.</td>
</tr>
<tr valign=top>
<td><a href="ov_test_callbacks.html">ov_test_callbacks</a></td>
<td>As above but allowing application-define I/O callbacks.<p>
Note that libvorbisfile owns the passed in file resource is it returns success; do not <tt>fclose()</tt> files owned by libvorbisfile.</td>
</tr>
<tr valign=top>
<td><a href="ov_test_open.html">ov_test_open</a><td>
Finish opening a file after a successful call to <a href="ov_test.html">ov_test()</a> or <a href="ov_test_callbacks.html">ov_test_callbacks()</a>.</td>
</tr>
<tr valign=top>
<td><a href="ov_clear.html">ov_clear</a></td> <td>Closes the
bitstream and cleans up loose ends. Must be called when
finished with the bitstream. After return, the <a
href="OggVorbis_File.html">OggVorbis_File</a> struct is
invalid and may not be used before being initialized again
before begin reinitialized.
</td>
</tr>
</table>
<br><br>
<hr noshade>
<table border=0 width=100%>
<tr valign=top>
<td><p class=tiny>copyright © 2007 Xiph.org</p></td>
<td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
</tr><tr>
<td><p class=tiny>Vorbisfile documentation</p></td>
<td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
</tr>
</table>
</body>
</html>