annotate src/libvorbis-1.3.3/doc/vorbisfile/ov_open.html @ 86:98c1576536ae

Bring in flac, ogg, vorbis
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 19 Mar 2013 17:37:49 +0000
parents
children
rev   line source
cannam@86 1 <html>
cannam@86 2
cannam@86 3 <head>
cannam@86 4 <title>Vorbisfile - function - ov_open</title>
cannam@86 5 <link rel=stylesheet href="style.css" type="text/css">
cannam@86 6 </head>
cannam@86 7
cannam@86 8 <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
cannam@86 9 <table border=0 width=100%>
cannam@86 10 <tr>
cannam@86 11 <td><p class=tiny>Vorbisfile documentation</p></td>
cannam@86 12 <td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
cannam@86 13 </tr>
cannam@86 14 </table>
cannam@86 15
cannam@86 16 <h1>ov_open</h1>
cannam@86 17
cannam@86 18 <p><i>declared in "vorbis/vorbisfile.h";</i></p>
cannam@86 19
cannam@86 20 <p>ov_open is one of three initialization functions used to initialize
cannam@86 21 an OggVorbis_File structure and prepare a bitstream for playback.
cannam@86 22
cannam@86 23 <p><em><b> WARNING for Windows developers: </b> Do not use ov_open() in
cannam@86 24 Windows applications; Windows linking places restrictions on
cannam@86 25 passing <tt>FILE *</tt> handles successfully, and ov_open() runs
cannam@86 26 afoul of these restrictions <a href="#winfoot">[a]</a>. See the <a
cannam@86 27 href="ov_open_callbacks.html">ov_open_callbacks() page </a> for
cannam@86 28 details on using <a
cannam@86 29 href="ov_open_callbacks.html">ov_open_callbacks()</a> instead. </em>
cannam@86 30
cannam@86 31 <p>The first argument must be a file pointer to an already opened file
cannam@86 32 or pipe (it need not be seekable--though this obviously restricts what
cannam@86 33 can be done with the bitstream). <tt>vf</tt> should be a pointer to the
cannam@86 34 OggVorbis_File structure -- this is used for ALL the externally visible libvorbisfile
cannam@86 35 functions. Once this has been called, the same <a href="OggVorbis_File.html">OggVorbis_File</a>
cannam@86 36 struct should be passed to all the libvorbisfile functions.<p>
cannam@86 37
cannam@86 38 The <tt>vf</tt> structure initialized using ov_fopen() must eventually
cannam@86 39 be cleaned using <a href="ov_clear.html">ov_clear()</a>. Once a
cannam@86 40 <tt>FILE *</tt> handle is passed to ov_open() successfully, the
cannam@86 41 application MUST NOT <tt>fclose()</tt> or in any other way manipulate
cannam@86 42 that file handle. Vorbisfile will close the file in <a
cannam@86 43 href="ov_clear.html">ov_clear()</a>. If the application must be able
cannam@86 44 to close the <tt>FILE *</tt> handle itself, see <a
cannam@86 45 href="ov_open_callbacks.html">ov_open_callbacks()</a> with the use of
cannam@86 46 <tt>OV_CALLBACKS_NOCLOSE</tt>.
cannam@86 47
cannam@86 48 <p>It is often useful to call <tt>ov_open()</tt> simply to determine
cannam@86 49 whether a given file is a Vorbis bitstream. If the <tt>ov_open()</tt>
cannam@86 50 call fails, then the file is not recognizable as Vorbis. If the call
cannam@86 51 succeeds but the initialized <tt>vf</tt> structure will not be used,
cannam@86 52 the application is responsible for calling <a
cannam@86 53 href="ov_clear.html">ov_clear()</a> to clear the decoder's buffers and
cannam@86 54 close the file.<p>
cannam@86 55
cannam@86 56 If [and only if] an <tt>ov_open()</tt> call fails, the application
cannam@86 57 must explicitly <tt>fclose()</tt> the <tt>FILE *</tt> pointer itself.
cannam@86 58
cannam@86 59
cannam@86 60 <br><br>
cannam@86 61 <table border=0 color=black cellspacing=0 cellpadding=7>
cannam@86 62 <tr bgcolor=#cccccc>
cannam@86 63 <td>
cannam@86 64 <pre><b>
cannam@86 65 int ov_open(FILE *f,<a href="OggVorbis_File.html">OggVorbis_File</a> *vf,char *initial,long ibytes);
cannam@86 66 </b></pre>
cannam@86 67 </td>
cannam@86 68 </tr>
cannam@86 69 </table>
cannam@86 70
cannam@86 71 <h3>Parameters</h3>
cannam@86 72 <dl>
cannam@86 73 <dt><i>f</i></dt>
cannam@86 74 <dd>File pointer to an already opened file
cannam@86 75 or pipe (it need not be seekable--though this obviously restricts what
cannam@86 76 can be done with the bitstream).</dd>
cannam@86 77 <dt><i>vf</i></dt>
cannam@86 78 <dd>A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile
cannam@86 79 functions. Once this has been called, the same <tt>OggVorbis_File</tt>
cannam@86 80 struct should be passed to all the libvorbisfile functions.</dd>
cannam@86 81 <dt><i>initial</i></dt>
cannam@86 82 <dd>Typically set to NULL. This parameter is useful if some data has already been
cannam@86 83 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>
cannam@86 84 should be a pointer to a buffer containing the data read.</dd>
cannam@86 85 <dt><i>ibytes</i></dt>
cannam@86 86 <dd>Typically set to 0. This parameter is useful if some data has already been
cannam@86 87 read from the file and the stream is not seekable. In this case, <tt>ibytes</tt>
cannam@86 88 should contain the length (in bytes) of the buffer. Used together with <tt>initial</tt></dd>
cannam@86 89 </dl>
cannam@86 90
cannam@86 91
cannam@86 92 <h3>Return Values</h3>
cannam@86 93 <blockquote>
cannam@86 94 <li>0 indicates success</li>
cannam@86 95
cannam@86 96 <li>less than zero for failure:</li>
cannam@86 97 <ul>
cannam@86 98 <li>OV_EREAD - A read from media returned an error.</li>
cannam@86 99 <li>OV_ENOTVORBIS - Bitstream is not Vorbis data.</li>
cannam@86 100 <li>OV_EVERSION - Vorbis version mismatch.</li>
cannam@86 101 <li>OV_EBADHEADER - Invalid Vorbis bitstream header.</li>
cannam@86 102 <li>OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.</li>
cannam@86 103 </ul>
cannam@86 104 </blockquote>
cannam@86 105 <p>
cannam@86 106
cannam@86 107 <a name="notes"></a>
cannam@86 108 <h3>Notes</h3>
cannam@86 109 <dl>
cannam@86 110
cannam@86 111 <a name="winfoot"></a>
cannam@86 112 <dt><b>[a] Windows and ov_open()</b><p>
cannam@86 113
cannam@86 114 <dd>Under Windows, stdio file access is implemented in each of many
cannam@86 115 variants of crt.o, several of which are typically installed on any one
cannam@86 116 Windows machine. If libvorbisfile and the application using
cannam@86 117 libvorbisfile are not linked against the exact same
cannam@86 118 version/variant/build of crt.o (and they usually won't be, especially
cannam@86 119 using a prebuilt libvorbis DLL), <tt>FILE *</tt> handles cannot be
cannam@86 120 opened in the application and then passed to vorbisfile to be used
cannam@86 121 by stdio calls from vorbisfile's different version of CRT. For this
cannam@86 122 reason, using <a href="ov_open.html">ov_open()</a> under Windows
cannam@86 123 without careful, expert linking will typically cause a protection
cannam@86 124 fault. Windows programmers should use <a
cannam@86 125 href="ov_fopen.html">ov_fopen()</a> (which will only use libvorbis's
cannam@86 126 crt.o) or <a href="ov_open_callbacks.html">ov_open_callbacks()</a>
cannam@86 127 (which will only use the application's crt.o) instead.<p>
cannam@86 128
cannam@86 129 This warning only applies to Windows and only applies to <a
cannam@86 130 href="ov_open.html">ov_open()</a>. It is perfectly safe to use <a
cannam@86 131 href="ov_open.html">ov_open()</a> on all other platforms.<p>
cannam@86 132
cannam@86 133 For more information, see the following microsoft pages on <a
cannam@86 134 href="http://msdn2.microsoft.com/en-us/library/abx4dbyh(VS.80).aspx">C
cannam@86 135 runtime library linking</a> and a specific description of <a
cannam@86 136 href="http://msdn2.microsoft.com/en-us/library/ms235460(VS.80).aspx">restrictions
cannam@86 137 on passing CRT objects across DLL boundaries</a>.
cannam@86 138
cannam@86 139 <p>
cannam@86 140
cannam@86 141 <dt><b>[b] Threaded decode</b><p>
cannam@86 142 <dd>If your decoder is threaded, it is recommended that you NOT call
cannam@86 143 <tt>ov_open()</tt>
cannam@86 144 in the main control thread--instead, call <tt>ov_open()</tt> in your decode/playback
cannam@86 145 thread. This is important because <tt>ov_open()</tt> may be a fairly time-consuming
cannam@86 146 call, given that the full structure of the file is determined at this point,
cannam@86 147 which may require reading large parts of the file under certain circumstances
cannam@86 148 (determining all the logical bitstreams in one physical bitstream, for
cannam@86 149 example). See <a href="threads.html">Thread Safety</a> for other information on using libvorbisfile with threads.
cannam@86 150 <p>
cannam@86 151
cannam@86 152 <dt><b>[c] Mixed media streams</b><p>
cannam@86 153 <dd>
cannam@86 154 As of Vorbisfile release 1.2.0, Vorbisfile is able to access the
cannam@86 155 Vorbis content in mixed-media Ogg streams, not just Vorbis-only
cannam@86 156 streams. For example, Vorbisfile may be used to open and access the
cannam@86 157 audio from an Ogg stream consisting of Theora video and Vorbis audio.
cannam@86 158 Vorbisfile 1.2.0 decodes the first logical audio stream of each
cannam@86 159 physical stream section.<p>
cannam@86 160
cannam@86 161 <dt><b>[d] Faster testing for Vorbis files</b><p>
cannam@86 162 <dd><a href="ov_test.html">ov_test()</a> and <a
cannam@86 163 href="ov_test_callbacks.html">ov_test_callbacks()</a> provide less
cannam@86 164 computationally expensive ways to test a file for Vorbisness, but
cannam@86 165 require more setup code.<p>
cannam@86 166
cannam@86 167 </dl>
cannam@86 168
cannam@86 169 <br><br>
cannam@86 170 <hr noshade>
cannam@86 171 <table border=0 width=100%>
cannam@86 172 <tr valign=top>
cannam@86 173 <td><p class=tiny>copyright &copy; 2000-2010 Xiph.Org</p></td>
cannam@86 174 <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
cannam@86 175 </tr><tr>
cannam@86 176 <td><p class=tiny>Vorbisfile documentation</p></td>
cannam@86 177 <td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
cannam@86 178 </tr>
cannam@86 179 </table>
cannam@86 180
cannam@86 181 </body>
cannam@86 182
cannam@86 183 </html>