ov_callbacks.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <html>
  2. <head>
  3. <title>Vorbisfile - datatype - ov_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_callbacks</h1>
  14. <p><i>declared in "vorbis/codec.h"</i></p>
  15. <p>
  16. The ov_callbacks structure contains file manipulation function prototypes necessary for opening, closing, seeking, and location.
  17. <p>
  18. The ov_callbacks structure does not need to be user-defined if you are
  19. working with stdio-based file manipulation; the <a
  20. href="ov_fopen.html">ov_fopen()</a> and <a
  21. href="ov_open.html">ov_open()</a> calls internally provide default callbacks for
  22. stdio. ov_callbacks are defined and passed to <a
  23. href="ov_open_callbacks.html">ov_open_callbacks()</a> when
  24. implementing non-stdio based stream manipulation (such as playback
  25. from a memory buffer) or when <a
  26. href="ov_open.html#winfoot">ov_open()-style initialization from a <tt>FILE *</tt> is required under Windows [a]</a>.
  27. <p>
  28. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  29. <tr bgcolor=#cccccc>
  30. <td>
  31. <pre><b>typedef struct {
  32. size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
  33. int (*seek_func) (void *datasource, ogg_int64_t offset, int whence);
  34. int (*close_func) (void *datasource);
  35. long (*tell_func) (void *datasource);
  36. } ov_callbacks;</b></pre>
  37. </td>
  38. </tr>
  39. </table>
  40. <h3>Relevant Struct Members</h3>
  41. <dl>
  42. <dt><i>read_func</i></dt>
  43. <dd>Pointer to custom data reading function.</dd>
  44. <dt><i>seek_func</i></dt>
  45. <dd>Pointer to custom data seeking function. If the data source is not seekable (or the application wants the data source to be treated as unseekable at all times), the provided seek callback should always return -1 (failure) or the <tt>seek_func</tt> and <tt>tell_func</tt> fields should be set to NULL.</dd>
  46. <dt><i>close_func</i></dt>
  47. <dd>Pointer to custom data source closure function. Set to NULL if libvorbisfile should not attempt to automatically close the file/data handle.</dd>
  48. <dt><i>tell_func</i></dt>
  49. <dd>Pointer to custom data location function. If the data source is not seekable (or the application wants the data source to be treated as unseekable at all times), the provided tell callback should always return -1 (failure) or the <tt>seek_func</tt> and <tt>tell_func</tt> fields should be set to NULL.</dd>
  50. </dl>
  51. <p>
  52. <h3>Predefined callbacks</h3>
  53. The header vorbis/vorbisfile.h provides several predefined static ov_callbacks structures that may be passed to <a
  54. href="ov_open_callbacks.html">ov_open_callbacks()</a>:
  55. <dl>
  56. <dt><tt>OV_CALLBACKS_DEFAULT</tt><dd>
  57. These callbacks provide the same behavior as used internally by <a
  58. href="ov_fopen.html">ov_fopen()</a> and <a
  59. href="ov_open.html">ov_open()</a>.
  60. <dt><tt>OV_CALLBACKS_NOCLOSE</tt><dd>
  61. The same as <tt>OV_CALLBACKS_DEFAULT</tt>, but with the
  62. <tt>close_func</tt> field set to NULL. The most typical use would be
  63. to use <a href="ov_open_callbacks.html">ov_open_callbacks()</a> to
  64. provide the same behavior as <a href="ov_open.html">ov_open()</a>, but
  65. not close the file/data handle in <a
  66. href="ov_clear.html">ov_clear()</a>.
  67. <dt><tt>OV_CALLBACKS_STREAMONLY</tt><dd>
  68. A set of callbacks that set <tt>seek_func</tt> and <tt>tell_func</tt>
  69. to NULL, thus forcing strict streaming-only behavior regardless of
  70. whether or not the input is actually seekable.
  71. <dt><tt>OV_CALLBACKS_STREAMONLY_NOCLOSE</tt><dd>
  72. The same as <tt>OV_CALLBACKS_STREAMONLY</tt>, but with
  73. <tt>close_func</tt> also set to null, preventing libvorbisfile from
  74. attempting to close the file/data handle in <a
  75. href="ov_clear.html">ov_clear()</a>.
  76. </dl>
  77. <p>
  78. <h3>Examples and usage</h3>
  79. See <a href="callbacks.html">the callbacks and non-stdio I/O document</a> for more
  80. detailed information on required behavior of the various callback
  81. functions.<p>
  82. <br><br>
  83. <hr noshade>
  84. <table border=0 width=100%>
  85. <tr valign=top>
  86. <td><p class=tiny>copyright &copy; 2007 Xiph.org</p></td>
  87. <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
  88. </tr><tr>
  89. <td><p class=tiny>Vorbisfile documentation</p></td>
  90. <td align=right><p class=tiny>vorbisfile version 1.2.0 - 20070723</p></td>
  91. </tr>
  92. </table>
  93. </body>
  94. </html>