Don Turner | 41d01d7 | 2019-06-21 16:18:52 +0100 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 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"/> |
Don Turner | 41d01d7 | 2019-06-21 16:18:52 +0100 | [diff] [blame] | 6 | <meta name="generator" content="Doxygen 1.8.15"/> |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 7 | <meta name="viewport" content="width=device-width, initial-scale=1"/> |
| 8 | <title>Oboe: include/oboe/LatencyTuner.h Source File</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 |
Don Turner | 69c8eb1 | 2020-11-26 18:35:52 +0000 | [diff] [blame] | 25 |  <span id="projectnumber">1.5</span> |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 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 --> |
Don Turner | 41d01d7 | 2019-06-21 16:18:52 +0100 | [diff] [blame] | 34 | <!-- Generated by Doxygen 1.8.15 --> |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 35 | <script type="text/javascript"> |
| 36 | /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&dn=gpl-2.0.txt GPL-v2 */ |
| 37 | var 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&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="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_768f6301d9838e45d679001914ab2803.html">oboe</a></li> </ul> |
| 67 | </div> |
| 68 | </div><!-- top --> |
| 69 | <div class="header"> |
| 70 | <div class="headertitle"> |
| 71 | <div class="title">LatencyTuner.h</div> </div> |
| 72 | </div><!--header--> |
| 73 | <div class="contents"> |
Don Turner | 69c8eb1 | 2020-11-26 18:35:52 +0000 | [diff] [blame] | 74 | <div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno"> 1</span> <span class="comment">/*</span></div><div class="line"><a name="l00002"></a><span class="lineno"> 2</span> <span class="comment"> * Copyright 2017 The Android Open Source Project</span></div><div class="line"><a name="l00003"></a><span class="lineno"> 3</span> <span class="comment"> *</span></div><div class="line"><a name="l00004"></a><span class="lineno"> 4</span> <span class="comment"> * Licensed under the Apache License, Version 2.0 (the "License");</span></div><div class="line"><a name="l00005"></a><span class="lineno"> 5</span> <span class="comment"> * you may not use this file except in compliance with the License.</span></div><div class="line"><a name="l00006"></a><span class="lineno"> 6</span> <span class="comment"> * You may obtain a copy of the License at</span></div><div class="line"><a name="l00007"></a><span class="lineno"> 7</span> <span class="comment"> *</span></div><div class="line"><a name="l00008"></a><span class="lineno"> 8</span> <span class="comment"> * http://www.apache.org/licenses/LICENSE-2.0</span></div><div class="line"><a name="l00009"></a><span class="lineno"> 9</span> <span class="comment"> *</span></div><div class="line"><a name="l00010"></a><span class="lineno"> 10</span> <span class="comment"> * Unless required by applicable law or agreed to in writing, software</span></div><div class="line"><a name="l00011"></a><span class="lineno"> 11</span> <span class="comment"> * distributed under the License is distributed on an "AS IS" BASIS,</span></div><div class="line"><a name="l00012"></a><span class="lineno"> 12</span> <span class="comment"> * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><div class="line"><a name="l00013"></a><span class="lineno"> 13</span> <span class="comment"> * See the License for the specific language governing permissions and</span></div><div class="line"><a name="l00014"></a><span class="lineno"> 14</span> <span class="comment"> * limitations under the License.</span></div><div class="line"><a name="l00015"></a><span class="lineno"> 15</span> <span class="comment"> */</span></div><div class="line"><a name="l00016"></a><span class="lineno"> 16</span> </div><div class="line"><a name="l00017"></a><span class="lineno"> 17</span> <span class="preprocessor">#ifndef OBOE_LATENCY_TUNER_</span></div><div class="line"><a name="l00018"></a><span class="lineno"> 18</span> <span class="preprocessor">#define OBOE_LATENCY_TUNER_</span></div><div class="line"><a name="l00019"></a><span class="lineno"> 19</span> </div><div class="line"><a name="l00020"></a><span class="lineno"> 20</span> <span class="preprocessor">#include <atomic></span></div><div class="line"><a name="l00021"></a><span class="lineno"> 21</span> <span class="preprocessor">#include <cstdint></span></div><div class="line"><a name="l00022"></a><span class="lineno"> 22</span> <span class="preprocessor">#include "oboe/Definitions.h"</span></div><div class="line"><a name="l00023"></a><span class="lineno"> 23</span> <span class="preprocessor">#include "oboe/AudioStream.h"</span></div><div class="line"><a name="l00024"></a><span class="lineno"> 24</span> </div><div class="line"><a name="l00025"></a><span class="lineno"> 25</span> <span class="keyword">namespace </span><a class="code" href="namespaceoboe.html">oboe</a> {</div><div class="line"><a name="l00026"></a><span class="lineno"> 26</span> </div><div class="line"><a name="l00041"></a><span class="lineno"><a class="line" href="classoboe_1_1_latency_tuner.html"> 41</a></span> <span class="keyword">class </span><a class="code" href="classoboe_1_1_latency_tuner.html">LatencyTuner</a> {</div><div class="line"><a name="l00042"></a><span class="lineno"> 42</span> <span class="keyword">public</span>:</div><div class="line"><a name="l00043"></a><span class="lineno"> 43</span> </div><div class="line"><a name="l00049"></a><span class="lineno"> 49</span>  <span class="keyword">explicit</span> <a class="code" href="classoboe_1_1_latency_tuner.html#a0263b9a55825c0a403653b2b508073ea">LatencyTuner</a>(<a class="code" href="classoboe_1_1_audio_stream.html">AudioStream</a> &stream);</div><div class="line"><a name="l00050"></a><span class="lineno"> 50</span> </div><div class="line"><a name="l00057"></a><span class="lineno"> 57</span>  <span class="keyword">explicit</span> <a class="code" href="classoboe_1_1_latency_tuner.html#a0263b9a55825c0a403653b2b508073ea">LatencyTuner</a>(<a class="code" href="classoboe_1_1_audio_stream.html">AudioStream</a> &stream, int32_t maximumBufferSize);</div><div class="line"><a name="l00058"></a><span class="lineno"> 58</span> </div><div class="line"><a name="l00067"></a><span class="lineno"> 67</span>  <a class="code" href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">Result</a> <a class="code" href="classoboe_1_1_latency_tuner.html#ad2be756965e6a9af3114008eda892174">tune</a>();</div><div class="line"><a name="l00068"></a><span class="lineno"> 68</span> </div><div class="line"><a name="l00077"></a><span class="lineno"> 77</span>  <span class="keywordtype">void</span> <a class="code" href="classoboe_1_1_latency_tuner.html#a6c0142e08dc65eda8f758b4794450867">requestReset</a>();</div><div class="line"><a name="l00078"></a><span class="lineno"> 78</span> </div><div class="line"><a name="l00084"></a><span class="lineno"> 84</span>  <span class="keywordtype">bool</span> <a class="code" href="classoboe_1_1_latency_tuner.html#a45c013fd6787ad09d328385d6314c4d4">isAtMaximumBufferSize</a>();</div><div class="line"><a name="l00085"></a><span class="lineno"> 85</span> </div><div class="line"><a name="l00091"></a><span class="lineno"><a class="line" href="classoboe_1_1_latency_tuner.html#adc96aa53b18a051b6ccdacb838139bf8"> 91</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoboe_1_1_latency_tuner.html#adc96aa53b18a051b6ccdacb838139bf8">setMinimumBufferSize</a>(int32_t bufferSize) {</div><div class="line"><a name="l00092"></a><span class="lineno"> 92</span>  mMinimumBufferSize = bufferSize;</div><div class="line"><a name="l00093"></a><span class="lineno"> 93</span>  }</div><div class="line"><a name="l00094"></a><span class="lineno"> 94</span> </div><div class="line"><a name="l00095"></a><span class="lineno"> 95</span>  int32_t getMinimumBufferSize()<span class="keyword"> const </span>{</div><div class="line"><a name="l00096"></a><span class="lineno"> 96</span>  <span class="keywordflow">return</span> mMinimumBufferSize;</div><div class="line"><a name="l00097"></a><span class="lineno"> 97</span>  }</div><div class="line"><a name="l00098"></a><span class="lineno"> 98</span> </div><div class="line"><a name="l00108"></a><span class="lineno"><a class="line" href="classoboe_1_1_latency_tuner.html#a2684b30205126c8acd2f75d01cce05db"> 108</a></span>  <span class="keywordtype">void</span> <a class="code" href="classoboe_1_1_latency_tuner.html#a2684b30205126c8acd2f75d01cce05db">setBufferSizeIncrement</a>(int32_t sizeIncrement) {</div><div class="line"><a name="l00109"></a><span class="lineno"> 109</span>  mBufferSizeIncrement = sizeIncrement;</div><div class="line"><a name="l00110"></a><span class="lineno"> 110</span>  }</div><div class="line"><a name="l00111"></a><span class="lineno"> 111</span> </div><div class="line"><a name="l00112"></a><span class="lineno"> 112</span>  int32_t getBufferSizeIncrement()<span class="keyword"> const </span>{</div><div class="line"><a name="l00113"></a><span class="lineno"> 113</span>  <span class="keywordflow">return</span> mBufferSizeIncrement;</div><div class="line"><a name="l00114"></a><span class="lineno"> 114</span>  }</div><div class="line"><a name="l00115"></a><span class="lineno"> 115</span> </div><div class="line"><a name="l00116"></a><span class="lineno"> 116</span> <span class="keyword">private</span>:</div><div class="line"><a name="l00117"></a><span class="lineno"> 117</span> </div><div class="line"><a name="l00124"></a><span class="lineno"> 124</span>  <span class="keywordtype">void</span> reset();</div><div class="line"><a name="l00125"></a><span class="lineno"> 125</span> </div><div class="line"><a name="l00126"></a><span class="lineno"> 126</span>  <span class="keyword">enum class</span> State {</div><div class="line"><a name="l00127"></a><span class="lineno"> 127</span>  Idle,</div><div class="line"><a name="l00128"></a><span class="lineno"> 128</span>  Active,</div><div class="line"><a name="l00129"></a><span class="lineno"> 129</span>  AtMax,</div><div class="line"><a name="l00130"></a><span class="lineno"> 130</span>  Unsupported</div><div class="line"><a name="l00131"></a><span class="lineno"> 131</span>  } ;</div><div class="line"><a name="l00132"></a><span class="lineno"> 132</span> </div><div class="line"><a name="l00133"></a><span class="lineno"> 133</span>  <span class="comment">// arbitrary number of calls to wait before bumping up the latency</span></div><div class="line"><a name="l00134"></a><span class="lineno"> 134</span>  <span class="keyword">static</span> constexpr int32_t kIdleCount = 8;</div><div class="line"><a name="l00135"></a><span class="lineno"> 135</span>  <span class="keyword">static</span> constexpr int32_t kDefaultNumBursts = 2;</div><div class="line"><a name="l00136"></a><span class="lineno"> 136</span> </div><div class="line"><a name="l00137"></a><span class="lineno"> 137</span>  AudioStream &mStream;</div><div class="line"><a name="l00138"></a><span class="lineno"> 138</span>  State mState = State::Idle;</div><div class="line"><a name="l00139"></a><span class="lineno"> 139</span>  int32_t mMaxBufferSize = 0;</div><div class="line"><a name="l00140"></a><span class="lineno"> 140</span>  int32_t mPreviousXRuns = 0;</div><div class="line"><a name="l00141"></a><span class="lineno"> 141</span>  int32_t mIdleCountDown = 0;</div><div class="line"><a name="l00142"></a><span class="lineno"> 142</span>  int32_t mMinimumBufferSize;</div><div class="line"><a name="l00143"></a><span class="lineno"> 143</span>  int32_t mBufferSizeIncrement;</div><div class="line"><a name="l00144"></a><span class="lineno"> 144</span>  std::atomic<int32_t> mLatencyTriggerRequests{0}; <span class="comment">// TODO user atomic requester from AAudio</span></div><div class="line"><a name="l00145"></a><span class="lineno"> 145</span>  std::atomic<int32_t> mLatencyTriggerResponses{0};</div><div class="line"><a name="l00146"></a><span class="lineno"> 146</span> };</div><div class="line"><a name="l00147"></a><span class="lineno"> 147</span> </div><div class="line"><a name="l00148"></a><span class="lineno"> 148</span> } <span class="comment">// namespace oboe</span></div><div class="line"><a name="l00149"></a><span class="lineno"> 149</span> </div><div class="line"><a name="l00150"></a><span class="lineno"> 150</span> <span class="preprocessor">#endif // OBOE_LATENCY_TUNER_</span></div><div class="ttc" id="classoboe_1_1_latency_tuner_html_a2684b30205126c8acd2f75d01cce05db"><div class="ttname"><a href="classoboe_1_1_latency_tuner.html#a2684b30205126c8acd2f75d01cce05db">oboe::LatencyTuner::setBufferSizeIncrement</a></div><div class="ttdeci">void setBufferSizeIncrement(int32_t sizeIncrement)</div><div class="ttdef"><b>Definition:</b> LatencyTuner.h:108</div></div> |
| 75 | <div class="ttc" id="classoboe_1_1_latency_tuner_html_a6c0142e08dc65eda8f758b4794450867"><div class="ttname"><a href="classoboe_1_1_latency_tuner.html#a6c0142e08dc65eda8f758b4794450867">oboe::LatencyTuner::requestReset</a></div><div class="ttdeci">void requestReset()</div></div> |
Don Turner | 41d01d7 | 2019-06-21 16:18:52 +0100 | [diff] [blame] | 76 | <div class="ttc" id="classoboe_1_1_audio_stream_html"><div class="ttname"><a href="classoboe_1_1_audio_stream.html">oboe::AudioStream</a></div><div class="ttdef"><b>Definition:</b> AudioStream.h:44</div></div> |
| 77 | <div class="ttc" id="classoboe_1_1_latency_tuner_html_a45c013fd6787ad09d328385d6314c4d4"><div class="ttname"><a href="classoboe_1_1_latency_tuner.html#a45c013fd6787ad09d328385d6314c4d4">oboe::LatencyTuner::isAtMaximumBufferSize</a></div><div class="ttdeci">bool isAtMaximumBufferSize()</div></div> |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 78 | <div class="ttc" id="classoboe_1_1_latency_tuner_html_a0263b9a55825c0a403653b2b508073ea"><div class="ttname"><a href="classoboe_1_1_latency_tuner.html#a0263b9a55825c0a403653b2b508073ea">oboe::LatencyTuner::LatencyTuner</a></div><div class="ttdeci">LatencyTuner(AudioStream &stream)</div></div> |
| 79 | <div class="ttc" id="classoboe_1_1_latency_tuner_html_ad2be756965e6a9af3114008eda892174"><div class="ttname"><a href="classoboe_1_1_latency_tuner.html#ad2be756965e6a9af3114008eda892174">oboe::LatencyTuner::tune</a></div><div class="ttdeci">Result tune()</div></div> |
Don Turner | 41d01d7 | 2019-06-21 16:18:52 +0100 | [diff] [blame] | 80 | <div class="ttc" id="namespaceoboe_html_a486512e787b609c80ba4436f23929af1"><div class="ttname"><a href="namespaceoboe.html#a486512e787b609c80ba4436f23929af1">oboe::Result</a></div><div class="ttdeci">Result</div><div class="ttdef"><b>Definition:</b> Definitions.h:131</div></div> |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 81 | <div class="ttc" id="classoboe_1_1_latency_tuner_html"><div class="ttname"><a href="classoboe_1_1_latency_tuner.html">oboe::LatencyTuner</a></div><div class="ttdef"><b>Definition:</b> LatencyTuner.h:41</div></div> |
Don Turner | 69c8eb1 | 2020-11-26 18:35:52 +0000 | [diff] [blame] | 82 | <div class="ttc" id="classoboe_1_1_latency_tuner_html_adc96aa53b18a051b6ccdacb838139bf8"><div class="ttname"><a href="classoboe_1_1_latency_tuner.html#adc96aa53b18a051b6ccdacb838139bf8">oboe::LatencyTuner::setMinimumBufferSize</a></div><div class="ttdeci">void setMinimumBufferSize(int32_t bufferSize)</div><div class="ttdef"><b>Definition:</b> LatencyTuner.h:91</div></div> |
Don Turner | 41d01d7 | 2019-06-21 16:18:52 +0100 | [diff] [blame] | 83 | <div class="ttc" id="namespaceoboe_html"><div class="ttname"><a href="namespaceoboe.html">oboe</a></div><div class="ttdef"><b>Definition:</b> AudioStream.h:31</div></div> |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 84 | </div><!-- fragment --></div><!-- contents --> |
| 85 | <!-- start footer part --> |
| 86 | <hr class="footer"/><address class="footer"><small> |
| 87 | Generated by  <a href="http://www.doxygen.org/index.html"> |
| 88 | <img class="footer" src="doxygen.png" alt="doxygen"/> |
Don Turner | 41d01d7 | 2019-06-21 16:18:52 +0100 | [diff] [blame] | 89 | </a> 1.8.15 |
Don Turner | fadd2b4 | 2018-09-20 12:16:36 +0100 | [diff] [blame] | 90 | </small></address> |
| 91 | </body> |
| 92 | </html> |