summaryrefslogtreecommitdiffhomepage
path: root/doc/vorbisfile/ov_callbacks.html
blob: d1b64be895c501799a01e2e778f8d6d1c170c470 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<html>

<head>
<title>Vorbisfile - datatype - ov_callbacks</title>
<link rel=stylesheet href="style.css" type="text/css">
</head>

<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
<table border=0 width=100%>
<tr>
<td><p class=tiny>Vorbisfile documentation</p></td>
<td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
</tr>
</table>

<h1>ov_callbacks</h1>

<p><i>declared in "vorbis/codec.h"</i></p>

<p>
The ov_callbacks structure contains file manipulation function prototypes necessary for opening, closing, seeking, and location.

<p>
The ov_callbacks structure does not need to be user-defined if you are
working with stdio-based file manipulation; the <a
href="ov_fopen.html">ov_fopen()</a> and <a
href="ov_open.html">ov_open()</a> calls internally provide default callbacks for
stdio.  ov_callbacks are defined and passed to <a
href="ov_open_callbacks.html">ov_open_callbacks()</a> when
implementing non-stdio based stream manipulation (such as playback
from a memory buffer) or when <a
href="ov_open.html#winfoot">ov_open()-style initialization from a <tt>FILE *</tt> is required under Windows [a]</a>.
<p>

<table border=0 width=100% color=black cellspacing=0 cellpadding=7>
<tr bgcolor=#cccccc>
	<td>
<pre><b>typedef struct {
  size_t (*read_func)  (void *ptr, size_t size, size_t nmemb, void *datasource);
  int    (*seek_func)  (void *datasource, ogg_int64_t offset, int whence);
  int    (*close_func) (void *datasource);
  long   (*tell_func)  (void *datasource);
} ov_callbacks;</b></pre>
	</td>
</tr>
</table>

<h3>Relevant Struct Members</h3>
<dl>
<dt><i>read_func</i></dt>
<dd>Pointer to custom data reading function.</dd>
<dt><i>seek_func</i></dt>
<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>
<dt><i>close_func</i></dt>
<dd>Pointer to custom data source closure function.  Set to NULL if libvorbisfile should not attempt to automatically close the file/data handle.</dd>
<dt><i>tell_func</i></dt>
<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>
</dl>

<p>

<h3>Predefined callbacks</h3>
The header vorbis/vorbisfile.h provides several predefined static ov_callbacks structures that may be passed to <a
href="ov_open_callbacks.html">ov_open_callbacks()</a>:
<dl>
<dt><tt>OV_CALLBACKS_DEFAULT</tt><dd>

These callbacks provide the same behavior as used internally by <a
href="ov_fopen.html">ov_fopen()</a> and <a
href="ov_open.html">ov_open()</a>.

<dt><tt>OV_CALLBACKS_NOCLOSE</tt><dd>

The same as <tt>OV_CALLBACKS_DEFAULT</tt>, but with the
<tt>close_func</tt> field set to NULL.  The most typical use would be
to use <a href="ov_open_callbacks.html">ov_open_callbacks()</a> to
provide the same behavior as <a href="ov_open.html">ov_open()</a>, but
not close the file/data handle in <a
href="ov_clear.html">ov_clear()</a>.

<dt><tt>OV_CALLBACKS_STREAMONLY</tt><dd>

A set of callbacks that set <tt>seek_func</tt> and <tt>tell_func</tt>
to NULL, thus forcing strict streaming-only behavior regardless of
whether or not the input is actually seekable.

<dt><tt>OV_CALLBACKS_STREAMONLY_NOCLOSE</tt><dd>

The same as <tt>OV_CALLBACKS_STREAMONLY</tt>, but with
<tt>close_func</tt> also set to null, preventing libvorbisfile from
attempting to close the file/data handle in <a
href="ov_clear.html">ov_clear()</a>.

</dl>
<p>

<h3>Examples and usage</h3>

See <a href="callbacks.html">the callbacks and non-stdio I/O document</a> for more
detailed information on required behavior of the various callback
functions.<p>

<br><br>
<hr noshade>
<table border=0 width=100%>
<tr valign=top>
<td><p class=tiny>copyright &copy; 2000-2010 Xiph.Org</p></td>
<td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td>
</tr><tr>
<td><p class=tiny>Vorbisfile documentation</p></td>
<td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
</tr>
</table>

</body>

</html>