annotate src/libvorbis-1.3.3/doc/vorbisfile/ov_open.html @ 1:05aa0afa9217

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