ov_open_callbacks.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <html>
  2. <head>
  3. <title>Vorbisfile - function - ov_open_callbacks</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_callbacks</h1>
  14. <p><i>declared in "vorbis/vorbisfile.h";</i></p>
  15. <p>This is an alternative function used to open and initialize an
  16. OggVorbis_File structure when using a data source other than a file,
  17. when its necessary to modify default file access behavior, or to
  18. initialize a Vorbis decode from a <tt>FILE *</tt> pointer under
  19. Windows where <a href="ov_open.html">ov_open()</a> cannot be used. It
  20. allows the application to specify custom file manipulation routines
  21. and sets up all the related decoding structures.
  22. <p>Once ov_open_callbacks() has been called, the same
  23. <tt>OggVorbis_File</tt> struct should be passed to all the
  24. libvorbisfile functions. Unlike <a
  25. href="ov_fopen.html">ov_fopen()</a> and <a
  26. href="ov_open.html">ov_open()</a>, ov_open_callbacks() may be used to
  27. instruct vorbisfile to either automatically close or not to close the
  28. file/data access handle in <a href="ov_clear.html">ov_clear()</a>.
  29. Automatic closure is disabled by passing NULL as the close callback,
  30. or using one of the predefined callback sets that specify a NULL close
  31. callback. The application is responsible for closing a file when a
  32. call to ov_open_callbacks() is unsuccessful.<p>
  33. See also <a href="callbacks.html">Callbacks and Non-stdio I/O</a> for
  34. information on designing and specifying custom callback functions.<p>
  35. <br><br>
  36. <table border=0 color=black cellspacing=0 cellpadding=7>
  37. <tr bgcolor=#cccccc>
  38. <td>
  39. <pre><b>
  40. int ov_open_callbacks(void *datasource, <a href="OggVorbis_File.html">OggVorbis_File</a> *vf, char *initial, long ibytes, <a href="ov_callbacks.html">ov_callbacks</a> callbacks);
  41. </b></pre>
  42. </td>
  43. </tr>
  44. </table>
  45. <h3>Parameters</h3>
  46. <dl>
  47. <dt><i>datasource</i></dt>
  48. <dd>Pointer to a data structure allocated by the calling application, containing any state needed by the callbacks provided.</dd>
  49. <dt><i>vf</i></dt>
  50. <dd>A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile
  51. functions. Once this has been called, the same <tt>OggVorbis_File</tt>
  52. struct should be passed to all the libvorbisfile functions.</dd>
  53. <dt><i>initial</i></dt>
  54. <dd>Typically set to NULL. This parameter is useful if some data has already been
  55. read from the stream and the stream is not seekable. It is used in conjunction with <tt>ibytes</tt>. In this case, <tt>initial</tt>
  56. should be a pointer to a buffer containing the data read.</dd>
  57. <dt><i>ibytes</i></dt>
  58. <dd>Typically set to 0. This parameter is useful if some data has already been
  59. read from the stream and the stream is not seekable. In this case, <tt>ibytes</tt>
  60. should contain the length (in bytes) of the buffer. Used together with <tt>initial</tt>.</dd>
  61. <dt><i>callbacks</i></dt>
  62. <dd>A completed <a href="ov_callbacks.html">ov_callbacks</a> struct which indicates desired custom file manipulation routines. vorbisfile.h defines several preprovided callback sets; see <a href="ov_callbacks.html">ov_callbacks</a> for details.</dd>
  63. </dl>
  64. <h3>Return Values</h3>
  65. <blockquote>
  66. <li>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 does not contain any 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. <dl>
  79. <dt><b>[a] Windows and use as an ov_open() substitute</b><p> Windows
  80. applications should not use <a href="ov_open.html">ov_open()</a> due
  81. to the likelihood of <a href="ov_open.html#winfoot">CRT linking
  82. mismatches and runtime protection faults
  83. [ov_open:a]</a>. ov_open_callbacks() is a safe substitute; specifically:
  84. <pre><tt>ov_open_callbacks(f, vf, initial, ibytes, OV_CALLBACKS_DEFAULT);</tt>
  85. </pre>
  86. ... provides exactly the same functionality as <a
  87. href="ov_open.html">ov_open()</a> but will always work correctly under
  88. Windows, regardless of linking setup details.<p>
  89. <dt><b>[b] Threaded decode</b><p>
  90. <dd>If your decoder is threaded, it is recommended that you NOT call
  91. <tt>ov_open_callbacks()</tt>
  92. in the main control thread--instead, call <tt>ov_open_callbacks()</tt> in your decode/playback
  93. thread. This is important because <tt>ov_open_callbacks()</tt> may be a fairly time-consuming
  94. call, given that the full structure of the file is determined at this point,
  95. which may require reading large parts of the file under certain circumstances
  96. (determining all the logical bitstreams in one physical bitstream, for
  97. example). See <a href="threads.html">Thread Safety</a> for other information on using libvorbisfile with threads.
  98. <p>
  99. <dt><b>[c] Mixed media streams</b><p>
  100. <dd>
  101. As of Vorbisfile release 1.2.0, Vorbisfile is able to access the
  102. Vorbis content in mixed-media Ogg streams, not just Vorbis-only
  103. streams. For example, Vorbisfile may be used to open and access the
  104. audio from an Ogg stream consisting of Theora video and Vorbis audio.
  105. Vorbisfile 1.2.0 decodes the first logical audio stream of each
  106. physical stream section.<p>
  107. <dt><b>[d] Faster testing for Vorbis files</b><p>
  108. <dd><a href="ov_test.html">ov_test()</a> and <a
  109. href="ov_test_callbacks.html">ov_test_callbacks()</a> provide less
  110. computationally expensive ways to test a file for Vorbisness, but
  111. require more setup code.<p>
  112. </dl>
  113. <br><br>
  114. <hr noshade>
  115. <table border=0 width=100%>
  116. <tr valign=top>
  117. <td><p class=tiny>copyright &copy; 2007 Xiph.org</p></td>
  118. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
  119. </tr><tr>
  120. <td><p class=tiny>Vorbisfile documentation</p></td>
  121. <td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
  122. </tr>
  123. </table>
  124. </body>
  125. </html>