1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html xmlns="http://www.w3.org/1999/xhtml">
3<head>
4<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
5<meta http-equiv="X-UA-Compatible" content="IE=9"/>
6<meta name="generator" content="Doxygen 1.8.15"/>
7<meta name="viewport" content="width=device-width, initial-scale=1"/>
8<title>Oboe: oboe::AudioStreamDataCallback Class Reference</title>
9<link href="tabs.css" rel="stylesheet" type="text/css"/>
10<script type="text/javascript" src="jquery.js"></script>
11<script type="text/javascript" src="dynsections.js"></script>
12<link href="search/search.css" rel="stylesheet" type="text/css"/>
13<script type="text/javascript" src="search/searchdata.js"></script>
14<script type="text/javascript" src="search/search.js"></script>
15<link href="doxygen.css" rel="stylesheet" type="text/css" />
16</head>
17<body>
18<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
19<div id="titlearea">
20<table cellspacing="0" cellpadding="0">
21 <tbody>
22 <tr style="height: 56px;">
23  <td id="projectalign" style="padding-left: 0.5em;">
24   <div id="projectname">Oboe
25   &#160;<span id="projectnumber">1.5</span>
26   </div>
27   <div id="projectbrief">A library for creating real-time audio apps on Android</div>
28  </td>
29 </tr>
30 </tbody>
31</table>
32</div>
33<!-- end header part -->
34<!-- Generated by Doxygen 1.8.15 -->
35<script type="text/javascript">
36/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
37var searchBox = new SearchBox("searchBox", "search",false,'Search');
38/* @license-end */
39</script>
40<script type="text/javascript" src="menudata.js"></script>
41<script type="text/javascript" src="menu.js"></script>
42<script type="text/javascript">
43/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
44$(function() {
45  initMenu('',true,false,'search.php','Search');
46  $(document).ready(function() { init_search(); });
47});
48/* @license-end */</script>
49<div id="main-nav"></div>
50<!-- window showing the filter options -->
51<div id="MSearchSelectWindow"
52     onmouseover="return searchBox.OnSearchSelectShow()"
53     onmouseout="return searchBox.OnSearchSelectHide()"
54     onkeydown="return searchBox.OnSearchSelectKey(event)">
55</div>
56
57<!-- iframe showing the search results (closed by default) -->
58<div id="MSearchResultsWindow">
59<iframe src="javascript:void(0)" frameborder="0"
60        name="MSearchResults" id="MSearchResults">
61</iframe>
62</div>
63
64<div id="nav-path" class="navpath">
65  <ul>
66<li class="navelem"><a class="el" href="namespaceoboe.html">oboe</a></li><li class="navelem"><a class="el" href="classoboe_1_1_audio_stream_data_callback.html">AudioStreamDataCallback</a></li>  </ul>
67</div>
68</div><!-- top -->
69<div class="header">
70  <div class="summary">
71<a href="#pub-methods">Public Member Functions</a> &#124;
72<a href="classoboe_1_1_audio_stream_data_callback-members.html">List of all members</a>  </div>
73  <div class="headertitle">
74<div class="title">oboe::AudioStreamDataCallback Class Reference<span class="mlabels"><span class="mlabel">abstract</span></span></div>  </div>
75</div><!--header-->
76<div class="contents">
77
78<p><code>#include &lt;<a class="el" href="_audio_stream_callback_8h_source.html">AudioStreamCallback.h</a>&gt;</code></p>
79<div class="dynheader">
80Inheritance diagram for oboe::AudioStreamDataCallback:</div>
81<div class="dyncontent">
82 <div class="center">
83  <img src="classoboe_1_1_audio_stream_data_callback.png" usemap="#oboe::AudioStreamDataCallback_map" alt=""/>
84  <map id="oboe::AudioStreamDataCallback_map" name="oboe::AudioStreamDataCallback_map">
85<area href="classoboe_1_1_audio_stream_callback.html" alt="oboe::AudioStreamCallback" shape="rect" coords="0,56,193,80"/>
86<area href="classoboe_1_1_stabilized_callback.html" alt="oboe::StabilizedCallback" shape="rect" coords="0,112,193,136"/>
87  </map>
88</div></div>
89<table class="memberdecls">
90<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
91Public Member Functions</h2></td></tr>
92<tr class="memitem:ad8a3a9f609df5fd3a5d885cbe1b2204d"><td class="memItemLeft" align="right" valign="top">virtual <a class="el" href="namespaceoboe.html#af85fc9910a287df6c5df0ed396bb75cd">DataCallbackResult</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classoboe_1_1_audio_stream_data_callback.html#ad8a3a9f609df5fd3a5d885cbe1b2204d">onAudioReady</a> (<a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *audioStream, void *audioData, int32_t numFrames)=0</td></tr>
93<tr class="separator:ad8a3a9f609df5fd3a5d885cbe1b2204d"><td class="memSeparator" colspan="2">&#160;</td></tr>
94</table>
95<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
96<div class="textblock"><p><a class="el" href="classoboe_1_1_audio_stream_data_callback.html">AudioStreamDataCallback</a> defines a callback interface for moving data to/from an audio stream using <code>onAudioReady</code> 2) being alerted when a stream has an error using <code>onError*</code> methods</p>
97<p>It is used with <a class="el" href="classoboe_1_1_audio_stream_builder.html#acad307720e0f370267b4e2f9a626ae70">AudioStreamBuilder::setDataCallback()</a>. </p>
98</div><h2 class="groupheader">Member Function Documentation</h2>
99<a id="ad8a3a9f609df5fd3a5d885cbe1b2204d"></a>
100<h2 class="memtitle"><span class="permalink"><a href="#ad8a3a9f609df5fd3a5d885cbe1b2204d">&#9670;&nbsp;</a></span>onAudioReady()</h2>
101
102<div class="memitem">
103<div class="memproto">
104<table class="mlabels">
105  <tr>
106  <td class="mlabels-left">
107      <table class="memname">
108        <tr>
109          <td class="memname">virtual <a class="el" href="namespaceoboe.html#af85fc9910a287df6c5df0ed396bb75cd">DataCallbackResult</a> oboe::AudioStreamDataCallback::onAudioReady </td>
110          <td>(</td>
111          <td class="paramtype"><a class="el" href="classoboe_1_1_audio_stream.html">AudioStream</a> *&#160;</td>
112          <td class="paramname"><em>audioStream</em>, </td>
113        </tr>
114        <tr>
115          <td class="paramkey"></td>
116          <td></td>
117          <td class="paramtype">void *&#160;</td>
118          <td class="paramname"><em>audioData</em>, </td>
119        </tr>
120        <tr>
121          <td class="paramkey"></td>
122          <td></td>
123          <td class="paramtype">int32_t&#160;</td>
124          <td class="paramname"><em>numFrames</em>&#160;</td>
125        </tr>
126        <tr>
127          <td></td>
128          <td>)</td>
129          <td></td><td></td>
130        </tr>
131      </table>
132  </td>
133  <td class="mlabels-right">
134<span class="mlabels"><span class="mlabel">pure virtual</span></span>  </td>
135  </tr>
136</table>
137</div><div class="memdoc">
138<p>A buffer is ready for processing.</p>
139<p>For an output stream, this function should render and write numFrames of data in the stream's current data format to the audioData buffer.</p>
140<p>For an input stream, this function should read and process numFrames of data from the audioData buffer.</p>
141<p>The audio data is passed through the buffer. So do NOT call read() or write() on the stream that is making the callback.</p>
142<p>Note that numFrames can vary unless <a class="el" href="classoboe_1_1_audio_stream_builder.html#a3f397821f61eabaeedaf31064c859a54">AudioStreamBuilder::setFramesPerCallback()</a> is called.</p>
143<p>Also note that this callback function should be considered a "real-time" function. It must not do anything that could cause an unbounded delay because that can cause the audio to glitch or pop.</p>
144<p>These are things the function should NOT do: </p><ul>
145<li>
146allocate memory using, for example, malloc() or new </li>
147<li>
148any file operations such as opening, closing, reading or writing </li>
149<li>
150any network operations such as streaming </li>
151<li>
152use any mutexes or other synchronization primitives </li>
153<li>
154sleep </li>
155<li>
156oboeStream-&gt;stop(), pause(), flush() or close() </li>
157<li>
158oboeStream-&gt;read() </li>
159<li>
160oboeStream-&gt;write() </li>
161</ul>
162<p>The following are OK to call from the data callback: </p><ul>
163<li>
164oboeStream-&gt;get*() </li>
165<li>
166<a class="el" href="namespaceoboe.html#af65aaea3c5d82eee6906664d61c094b3">oboe::convertToText()</a> </li>
167<li>
168oboeStream-&gt;setBufferSizeInFrames() </li>
169</ul>
170<p>If you need to move data, eg. MIDI commands, in or out of the callback function then we recommend the use of non-blocking techniques such as an atomic FIFO.</p>
171<dl class="params"><dt>Parameters</dt><dd>
172  <table class="params">
173    <tr><td class="paramname">audioStream</td><td>pointer to the associated stream </td></tr>
174    <tr><td class="paramname">audioData</td><td>buffer containing input data or a place to put output data </td></tr>
175    <tr><td class="paramname">numFrames</td><td>number of frames to be processed </td></tr>
176  </table>
177  </dd>
178</dl>
179<dl class="section return"><dt>Returns</dt><dd>DataCallbackResult::Continue or DataCallbackResult::Stop </dd></dl>
180
181<p>Implemented in <a class="el" href="classoboe_1_1_stabilized_callback.html#ad447e12ebf732cf151655c1fbaf58a49">oboe::StabilizedCallback</a>.</p>
182
183</div>
184</div>
185<hr/>The documentation for this class was generated from the following file:<ul>
186<li>include/oboe/<a class="el" href="_audio_stream_callback_8h_source.html">AudioStreamCallback.h</a></li>
187</ul>
188</div><!-- contents -->
189<!-- start footer part -->
190<hr class="footer"/><address class="footer"><small>
191Generated by &#160;<a href="http://www.doxygen.org/index.html">
192<img class="footer" src="doxygen.png" alt="doxygen"/>
193</a> 1.8.15
194</small></address>
195</body>
196</html>
197