ov_open.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <html>
  2. <head>
  3. <title>Tremor - 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>Tremor documentation</p></td>
  10. <td align=right><p class=tiny>Tremor version 1.0 - 20020403</p></td>
  11. </tr>
  12. </table>
  13. <h1>ov_open</h1>
  14. <p><i>declared in "ivorbisfile.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 libvorbisidec
  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 libvorbisidec 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.
  29. When you use <tt>ov_open()
  30. </tt>for
  31. this, you should <tt>fclose()</tt> the file pointer if, and only if, the
  32. <tt>ov_open()</tt>
  33. call fails. If it succeeds, you must call <a href="ov_clear.html">ov_clear()</a> to clear
  34. the decoder's buffers and close the file for you.<p>
  35. (Note that <a href="ov_test.html">ov_test()</a> provides a less expensive way to test a file for Vorbisness.)<p>
  36. <br><br>
  37. <table border=0 color=black cellspacing=0 cellpadding=7>
  38. <tr bgcolor=#cccccc>
  39. <td>
  40. <pre><b>
  41. int ov_open(FILE *f,<a href="OggVorbis_File.html">OggVorbis_File</a> *vf,char *initial,long ibytes);
  42. </b></pre>
  43. </td>
  44. </tr>
  45. </table>
  46. <h3>Parameters</h3>
  47. <dl>
  48. <dt><i>f</i></dt>
  49. <dd>File pointer to an already opened file
  50. or pipe (it need not be seekable--though this obviously restricts what
  51. can be done with the bitstream).</dd>
  52. <dt><i>vf</i></dt>
  53. <dd>A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
  54. functions. Once this has been called, the same <tt>OggVorbis_File</tt>
  55. struct should be passed to all the libvorbisidec functions.</dd>
  56. <dt><i>initial</i></dt>
  57. <dd>Typically set to NULL. This parameter is useful if some data has already been
  58. 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>
  59. should be a pointer to a buffer containing the data read.</dd>
  60. <dt><i>ibytes</i></dt>
  61. <dd>Typically set to 0. This parameter is useful if some data has already been
  62. read from the file and the stream is not seekable. In this case, <tt>ibytes</tt>
  63. should contain the length (in bytes) of the buffer. Used together with <tt>initial</tt></dd>
  64. </dl>
  65. <h3>Return Values</h3>
  66. <blockquote>
  67. <li>0 indicates success</li>
  68. <li>less than zero for failure:</li>
  69. <ul>
  70. <li>OV_EREAD - A read from media returned an error.</li>
  71. <li>OV_ENOTVORBIS - Bitstream is not Vorbis data.</li>
  72. <li>OV_EVERSION - Vorbis version mismatch.</li>
  73. <li>OV_EBADHEADER - Invalid Vorbis bitstream header.</li>
  74. <li>OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.</li>
  75. </ul>
  76. </blockquote>
  77. <p>
  78. <h3>Notes</h3>
  79. <p>If your decoder is threaded, it is recommended that you NOT call
  80. <tt>ov_open()</tt>
  81. in the main control thread--instead, call <tt>ov_open()</tt> IN your decode/playback
  82. thread. This is important because <tt>ov_open()</tt> may be a fairly time-consuming
  83. call, given that the full structure of the file is determined at this point,
  84. which may require reading large parts of the file under certain circumstances
  85. (determining all the logical bitstreams in one physical bitstream, for
  86. example). See <a href="threads.html">Thread Safety</a> for other information on using libvorbisidec with threads.
  87. <br><br>
  88. <hr noshade>
  89. <table border=0 width=100%>
  90. <tr valign=top>
  91. <td><p class=tiny>copyright &copy; 2002 Xiph.org</p></td>
  92. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
  93. </tr><tr>
  94. <td><p class=tiny>Tremor documentation</p></td>
  95. <td align=right><p class=tiny>Tremor version 1.0 - 20020403</p></td>
  96. </tr>
  97. </table>
  98. </body>
  99. </html>