ov_open.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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.25 - 20000615</p></td>
  11. </tr>
  12. </table>
  13. <h1>ov_open</h1>
  14. <p><i>declared in "vorbis/vorbisfile.h";</i></p>
  15. <p>This is the main function used to open and initialize an OggVorbis_File
  16. structure. It sets up all the related decoding structure.
  17. <p>The first argument must be a file pointer to an already opened file
  18. or pipe (it need not be seekable--though this obviously restricts what
  19. can be done with the bitstream). <tt>vf</tt> should be a pointer to the
  20. OggVorbis_File structure--this is used for ALL the externally visible vorbisfile
  21. functions. Once this has been called, the same <a href="OggVorbis_File.html">OggVorbis_File</a>
  22. struct should be passed to all the vorbisfile functions.
  23. <p>Also, you should be aware that ov_open(), once successful, takes complete possession of the file resource. After you have opened a file using ov_open(), you MUST close it using <a href="ov_clear.html">ov_clear()</a>, not fclose() or any other function.
  24. <p>
  25. It is often useful to call <tt>ov_open()</tt>
  26. simply to determine whether a given file is a vorbis bitstream. If the
  27. <tt>ov_open()</tt>
  28. call fails, then the file is not recognizable as such. When you use <tt>ov_open()
  29. </tt>for
  30. this, you should <tt>fclose()</tt> the file pointer if, and only if, the
  31. <tt>ov_open()</tt>
  32. call fails. If it succeeds, you must call <a href="ov_clear.html">ov_clear()</a> to clear
  33. the decoder's buffers and close the file for you.
  34. <br><br>
  35. <table border=0 color=black cellspacing=0 cellpadding=7>
  36. <tr bgcolor=#cccccc>
  37. <td>
  38. <pre><b>
  39. int ov_open(FILE *f,<a href="OggVorbis_File.html">OggVorbis_File</a> *vf,char *initial,long ibytes);
  40. </b></pre>
  41. </td>
  42. </tr>
  43. </table>
  44. <h3>Parameters</h3>
  45. <dl>
  46. <dt><i>f</i></dt>
  47. <dd>File pointer to an already opened file
  48. or pipe (it need not be seekable--though this obviously restricts what
  49. can be done with the bitstream).</dd>
  50. <dt><i>vf</i></dt>
  51. <dd>A pointer to the OggVorbis_File structure--this is used for ALL the externally visible vorbisfile
  52. functions. Once this has been called, the same <tt>OggVorbis_File</tt>
  53. struct should be passed to all the vorbisfile functions.</dd>
  54. <dt><i>initial</i></dt>
  55. <dd>Typically set to NULL. This parameter is useful if some data has already been
  56. 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>
  57. should be a pointer to a buffer containing the data read.</dd>
  58. <dt><i>ibytes</i></dt>
  59. <dd>Typically set to 0. This parameter is useful if some data has already been
  60. read from the file and the stream is not seekable. In this case, <tt>ibytes</tt>
  61. should contain the length (in bytes) of the buffer. Used together with <tt>initial</tt></dd>
  62. </dl>
  63. <h3>Return Values</h3>
  64. <blockquote>
  65. <li>
  66. 0 for success</li>
  67. <li>less than zero for failure:</li>
  68. <ul>
  69. <li>OV_EREAD - A read from media returned an error.</li>
  70. <li>OV_ENOTVORBIS - Bitstream is not Vorbis data.</li>
  71. <li>OV_EVERSION - Vorbis version mismatch.</li>
  72. <li>OV_EBADHEADER - Invalid Vorbis bitstream header.</li>
  73. <li>OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.</li>
  74. </ul>
  75. </blockquote>
  76. <p>
  77. <h3>Notes</h3>
  78. <p>If your decoder is threaded, it is recommended that you NOT call
  79. <tt>ov_open()</tt>
  80. in the main control thread--instead, call <tt>ov_open()</tt> IN your decode/playback
  81. thread. This is important because <tt>ov_open()</tt> may be a fairly time-consuming
  82. call, given that the full structure of the file is determined at this point,
  83. which may require reading large parts of the file under certain circumstances
  84. (determining all the logical bitstreams in one physical bitstream, for
  85. example).
  86. <br><br>
  87. <hr noshade>
  88. <table border=0 width=100%>
  89. <tr valign=top>
  90. <td><p class=tiny>copyright &copy; 2000 vorbis team</p></td>
  91. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a><br><a href="mailto:team@vorbis.org">team@vorbis.org</a></p></td>
  92. </tr><tr>
  93. <td><p class=tiny>vorbisfile documentation</p></td>
  94. <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>
  95. </tr>
  96. </table>
  97. </body>
  98. </html>