ov_callbacks.html 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.25 - 20000615</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 working with a standard file. The typical <a href="ov_open.html">ov_open()</a> call will fill ov_callbacks for you. However, ov_callbacks should be defined if you are using other data sources. In this situation, use <a href="ov_open_callbacks.html">ov_open_callbacks()</a> instead of <a href="ov_open.html">ov_open()</a>.
  19. <p>
  20. <p>
  21. The callbacks are designed following the stdio functions fread, fseek, fclose,
  22. and ftell. Except where otherwise noted below, they should work the same as
  23. these functions do.
  24. </p>
  25. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  26. <tr bgcolor=#cccccc>
  27. <td>
  28. <pre><b>typedef struct {
  29. size_t (*read_func) (void *ptr, size_t size, size_t nmemb, void *datasource);
  30. int (*seek_func) (void *datasource, int64_t offset, int whence);
  31. int (*close_func) (void *datasource);
  32. long (*tell_func) (void *datasource);
  33. } ov_callbacks;</b></pre>
  34. </td>
  35. </tr>
  36. </table>
  37. <h3>Relevant Struct Members</h3>
  38. <dl>
  39. <dt><i>read_func</i></dt>
  40. <dd>Pointer to custom data reading function. Read up to size*nmemb bytes from
  41. the source into the buffer at ptr. Return the number of bytes read successfully.
  42. Must return 0 if nothing can be read. Should also set errno if an error occurs,
  43. in order to distinguish between error and EOF.</dd>
  44. <dt><i>seek_func</i></dt>
  45. <dd>Pointer to custom data seeking function. If your data source does not support
  46. seeking, you <em>must</em> return -1. Returns 0 on success. Seeks to a position <em>offset</em> bytes from a position defined by <em>whence</em>. If whence is SEEK_SET, seek relative to the file start. If SEEK_CUR, seek is relative to current file position. If SEEK_END, relative to end of file.</dd>
  47. <dt><i>close_func</i></dt>
  48. <dd>Pointer to custom data source closure function. This should clear any
  49. resources used by the data source, such as open files or network sockets. Returns 0.</dd>
  50. <dt><i>tell_func</i></dt>
  51. <dd>Pointer to custom data location function. Returns the current offset (from the start) of the data stream. If your source is non-seekable, this need not be
  52. implemented.</dd>
  53. </dl>
  54. <br><br>
  55. <hr noshade>
  56. <table border=0 width=100%>
  57. <tr valign=top>
  58. <td><p class=tiny>copyright &copy; 2000 vorbis team</p></td>
  59. <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>
  60. </tr><tr>
  61. <td><p class=tiny>vorbisfile documentation</p></td>
  62. <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>
  63. </tr>
  64. </table>
  65. </body>
  66. </html>