ov_open.html 7.3 KB

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