blob: 208ef18b5cd1908627e30d576ab7f744c3484dce [file] [log] [blame]
<title>Tremor - function - ov_read</title>
<link rel=stylesheet href="style.css" type="text/css">
<body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
<table border=0 width=100%>
<td><p class=tiny>Tremor documentation</p></td>
<td align=right><p class=tiny>Tremor version 1.0 - 20020403</p></td>
<p><i>declared in "ivorbisfile.h";</i></p>
This is the main function used to decode a Vorbis file within a
loop. It returns up to the specified number of bytes of decoded audio
in host-endian, signed 16 bit PCM format. If the audio is
multichannel, the channels are interleaved in the output buffer.
If the passed in buffer is large, <tt>ov_read()</tt> will not fill
it; the passed in buffer size is treated as a <em>limit</em> and
not a request.
Note that up to this point, the Tremor API could more or less hide the
multiple logical bitstream nature of chaining from the toplevel
application if the toplevel application didn't particularly care.
However, when reading audio back, the application must be aware
that multiple bitstream sections do not necessarily use the same
number of channels or sampling rate. <p> <tt>ov_read()</tt> passes
back the index of the sequential logical bitstream currently being
decoded (in <tt>*bitstream</tt>) along with the PCM data in order
that the toplevel application can handle channel and/or sample
rate changes. This number will be incremented at chaining
boundaries even for non-seekable streams. For seekable streams, it
represents the actual chaining index within the physical bitstream.
<table border=0 color=black cellspacing=0 cellpadding=7>
<tr bgcolor=#cccccc>
long ov_read(<a href="OggVorbis_File.html">OggVorbis_File</a> *vf, char *buffer, int length, int *bitstream);
<dd>A pointer to the OggVorbis_File structure--this is used for ALL the externally visible libvorbisidec
<dd>A pointer to an output buffer. The decoded output is inserted into this buffer.</dd>
<dd>Number of bytes to be read into the buffer. Should be the same size as the buffer. A typical value is 4096.</dd>
<dd>A pointer to the number of the current logical bitstream.</dd>
<h3>Return Values</h3>
<dd>indicates there was an interruption in the data.
<br>(one of: garbage between pages, loss of sync followed by
recapture, or a corrupt page)</dd>
<dd>indicates that an invalid stream section was supplied to
libvorbisidec, or the requested link is corrupt.</dd>
<dd>indicates EOF</dd>
<dd>indicates actual number of bytes read. <tt>ov_read()</tt> will
decode at most one vorbis packet per invocation, so the value
returned will generally be less than <tt>length</tt>.
<p><b>Typical usage:</b>
<tt>bytes_read = ov_read(&amp;vf,
buffer, 4096,&amp;current_section)</tt>
This reads up to 4096 bytes into a buffer, with signed 16-bit
little-endian samples.
<hr noshade>
<table border=0 width=100%>
<tr valign=top>
<td><p class=tiny>copyright &copy; 2002</p></td>
<td align=right><p class=tiny><a href="">Ogg Vorbis</a></p></td>
<td><p class=tiny>Tremor documentation</p></td>
<td align=right><p class=tiny>Tremor version 1.0 - 20020403</p></td>