00001 <html> 00002 00003 <head> 00004 <title>Vorbisfile - function - ov_open_callbacks</title> 00005 <link rel=stylesheet href="style.css" type="text/css"> 00006 </head> 00007 00008 <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff"> 00009 <table border=0 width=100%> 00010 <tr> 00011 <td><p class=tiny>Vorbisfile documentation</p></td> 00012 <td align=right><p class=tiny>vorbisfile version 1.68 - 20030307</p></td> 00013 </tr> 00014 </table> 00015 00016 <h1>ov_open_callbacks</h1> 00017 00018 <p><i>declared in "vorbis/vorbisfile.h";</i></p> 00019 00020 <p>This is an alternative function used to open and initialize an OggVorbis_File 00021 structure when using a data source other than a file. It allows you to specify custom file manipulation routines and sets up all the related decoding structure. 00022 <p>Once this has been called, the same <tt>OggVorbis_File</tt> 00023 struct should be passed to all the libvorbisfile functions. 00024 <p> 00025 It is often useful to call <tt>ov_open_callbacks()</tt> 00026 simply to determine whether a given stream is a vorbis bitstream. If the 00027 <tt>ov_open_callbacks()</tt> 00028 call fails, then the data is not recognizable as such. When you use <tt>ov_open_callbacks() 00029 </tt>for 00030 this, you should close or otherwise deallocate your <tt>datasource</tt> if, and only if, the 00031 <tt>ov_open_callbacks()</tt> 00032 call fails. If it succeeds, you must call <a href=ov_clear.html>ov_clear()</a> to clear 00033 the decoder's buffers and call your close callback.<p> 00034 00035 See also <a href="callbacks.html">Callbacks and Non-stdio I/O</a> for information on designing and specifying the required callback functions.<p> 00036 00037 <br><br> 00038 <table border=0 color=black cellspacing=0 cellpadding=7> 00039 <tr bgcolor=#cccccc> 00040 <td> 00041 <pre><b> 00042 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); 00043 </b></pre> 00044 </td> 00045 </tr> 00046 </table> 00047 00048 <h3>Parameters</h3> 00049 <dl> 00050 <dt><i>datasource</i></dt> 00051 <dd>Pointer to a data structure allocated by the calling application, containing any state needed by the callbacks provided.</dd> 00052 <dt><i>vf</i></dt> 00053 <dd>A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisfile 00054 functions. Once this has been called, the same <tt>OggVorbis_File</tt> 00055 struct should be passed to all the libvorbisfile functions.</dd> 00056 <dt><i>initial</i></dt> 00057 <dd>Typically set to NULL. This parameter is useful if some data has already been 00058 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> 00059 should be a pointer to a buffer containing the data read.</dd> 00060 <dt><i>ibytes</i></dt> 00061 <dd>Typically set to 0. This parameter is useful if some data has already been 00062 read from the stream and the stream is not seekable. In this case, <tt>ibytes</tt> 00063 should contain the length (in bytes) of the buffer. Used together with <tt>initial</tt>.</dd> 00064 <dt><i>callbacks</i></dt> 00065 <dd>A completed <a href="ov_callbacks.html">ov_callbacks</a> struct which indicates desired custom file manipulation routines.</dd> 00066 </dl> 00067 00068 00069 <h3>Return Values</h3> 00070 <blockquote> 00071 <li>0 for success</li> 00072 <li>less than zero for failure:</li> 00073 <ul> 00074 <li>OV_EREAD - A read from media returned an error.</li> 00075 <li>OV_ENOTVORBIS - Bitstream is not Vorbis data.</li> 00076 <li>OV_EVERSION - Vorbis version mismatch.</li> 00077 <li>OV_EBADHEADER - Invalid Vorbis bitstream header.</li> 00078 <li>OV_EFAULT - Internal logic fault; indicates a bug or heap/stack corruption.</li> 00079 </ul> 00080 </blockquote> 00081 <p> 00082 00083 <h3>Notes</h3> 00084 <p>If your decoder is threaded, it is recommended that you NOT call 00085 <tt>ov_open_callbacks()</tt> 00086 in the main control thread--instead, call <tt>ov_open_callbacks()</tt> IN your decode/playback 00087 thread. This is important because <tt>ov_open_callbacks()</tt> may be a fairly time-consuming 00088 call, given that the full structure of the file is determined at this point, 00089 which may require reading large parts of the file under certain circumstances 00090 (determining all the logical bitstreams in one physical bitstream, for 00091 example). 00092 See <a href="threads.html">Thread Safety</a> for other information on using libvorbisfile with threads. 00093 00094 <br><br> 00095 <hr noshade> 00096 <table border=0 width=100%> 00097 <tr valign=top> 00098 <td><p class=tiny>copyright © 2003 Xiph.org</p></td> 00099 <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a></p></td> 00100 </tr><tr> 00101 <td><p class=tiny>Vorbisfile documentation</p></td> 00102 <td align=right><p class=tiny>vorbisfile version 1.68 - 20030307</p></td> 00103 </tr> 00104 </table> 00105 00106 </body> 00107 00108 </html>