/usr/share/doc/libjuce/apiref/classAbstractFifo.html is in libjuce-doc 4.3.0~repack-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.12"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>JUCE: AbstractFifo Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">JUCE
</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.12 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>
<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
name="MSearchResults" id="MSearchResults">
</iframe>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> |
<a href="classAbstractFifo-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">AbstractFifo Class Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>Encapsulates the logic required to implement a lock-free FIFO.
<a href="classAbstractFifo.html#details">More...</a></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:accd680c366b4b8ca4f30ee8fb2b37b75"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#accd680c366b4b8ca4f30ee8fb2b37b75">AbstractFifo</a> (int capacity) noexcept</td></tr>
<tr class="memdesc:accd680c366b4b8ca4f30ee8fb2b37b75"><td class="mdescLeft"> </td><td class="mdescRight">Creates a FIFO to manage a buffer with the specified capacity. <a href="#accd680c366b4b8ca4f30ee8fb2b37b75">More...</a><br /></td></tr>
<tr class="separator:accd680c366b4b8ca4f30ee8fb2b37b75"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a81ff19ff8eed394e9f7aca08ae1e8e8d"><td class="memItemLeft" align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a81ff19ff8eed394e9f7aca08ae1e8e8d">~AbstractFifo</a> ()</td></tr>
<tr class="memdesc:a81ff19ff8eed394e9f7aca08ae1e8e8d"><td class="mdescLeft"> </td><td class="mdescRight">Destructor. <a href="#a81ff19ff8eed394e9f7aca08ae1e8e8d">More...</a><br /></td></tr>
<tr class="separator:a81ff19ff8eed394e9f7aca08ae1e8e8d"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a7724b664c3aae6cbaad1a3821ccaf654"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a7724b664c3aae6cbaad1a3821ccaf654">getTotalSize</a> () const noexcept</td></tr>
<tr class="memdesc:a7724b664c3aae6cbaad1a3821ccaf654"><td class="mdescLeft"> </td><td class="mdescRight">Returns the total size of the buffer being managed. <a href="#a7724b664c3aae6cbaad1a3821ccaf654">More...</a><br /></td></tr>
<tr class="separator:a7724b664c3aae6cbaad1a3821ccaf654"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:aeb68b5aec74f6511c76df390eda588ee"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#aeb68b5aec74f6511c76df390eda588ee">getFreeSpace</a> () const noexcept</td></tr>
<tr class="memdesc:aeb68b5aec74f6511c76df390eda588ee"><td class="mdescLeft"> </td><td class="mdescRight">Returns the number of items that can currently be added to the buffer without it overflowing. <a href="#aeb68b5aec74f6511c76df390eda588ee">More...</a><br /></td></tr>
<tr class="separator:aeb68b5aec74f6511c76df390eda588ee"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a39ab3206298a1aabb4412a6993b4023b"><td class="memItemLeft" align="right" valign="top">int </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a39ab3206298a1aabb4412a6993b4023b">getNumReady</a> () const noexcept</td></tr>
<tr class="memdesc:a39ab3206298a1aabb4412a6993b4023b"><td class="mdescLeft"> </td><td class="mdescRight">Returns the number of items that can currently be read from the buffer. <a href="#a39ab3206298a1aabb4412a6993b4023b">More...</a><br /></td></tr>
<tr class="separator:a39ab3206298a1aabb4412a6993b4023b"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a33ba0f93c22c9cc182f8fa78af07862f"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a33ba0f93c22c9cc182f8fa78af07862f">reset</a> () noexcept</td></tr>
<tr class="memdesc:a33ba0f93c22c9cc182f8fa78af07862f"><td class="mdescLeft"> </td><td class="mdescRight">Clears the buffer positions, so that it appears empty. <a href="#a33ba0f93c22c9cc182f8fa78af07862f">More...</a><br /></td></tr>
<tr class="separator:a33ba0f93c22c9cc182f8fa78af07862f"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a5ece35129a957c8783411de69b2542ec"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a5ece35129a957c8783411de69b2542ec">setTotalSize</a> (int newSize) noexcept</td></tr>
<tr class="memdesc:a5ece35129a957c8783411de69b2542ec"><td class="mdescLeft"> </td><td class="mdescRight">Changes the buffer's total size. <a href="#a5ece35129a957c8783411de69b2542ec">More...</a><br /></td></tr>
<tr class="separator:a5ece35129a957c8783411de69b2542ec"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a9f32996a86817773a7165be823f80c87"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a9f32996a86817773a7165be823f80c87">prepareToWrite</a> (int numToWrite, int &startIndex1, int &blockSize1, int &startIndex2, int &blockSize2) const noexcept</td></tr>
<tr class="memdesc:a9f32996a86817773a7165be823f80c87"><td class="mdescLeft"> </td><td class="mdescRight">Returns the location within the buffer at which an incoming block of data should be written. <a href="#a9f32996a86817773a7165be823f80c87">More...</a><br /></td></tr>
<tr class="separator:a9f32996a86817773a7165be823f80c87"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a0daf6067beb737a4136e7e9d8f26bab0"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a0daf6067beb737a4136e7e9d8f26bab0">finishedWrite</a> (int numWritten) noexcept</td></tr>
<tr class="memdesc:a0daf6067beb737a4136e7e9d8f26bab0"><td class="mdescLeft"> </td><td class="mdescRight">Called after writing from the FIFO, to indicate that this many items have been added. <a href="#a0daf6067beb737a4136e7e9d8f26bab0">More...</a><br /></td></tr>
<tr class="separator:a0daf6067beb737a4136e7e9d8f26bab0"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a880ae9f1e0a08f3c0cfe95f03b279f96"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a880ae9f1e0a08f3c0cfe95f03b279f96">prepareToRead</a> (int numWanted, int &startIndex1, int &blockSize1, int &startIndex2, int &blockSize2) const noexcept</td></tr>
<tr class="memdesc:a880ae9f1e0a08f3c0cfe95f03b279f96"><td class="mdescLeft"> </td><td class="mdescRight">Returns the location within the buffer from which the next block of data should be read. <a href="#a880ae9f1e0a08f3c0cfe95f03b279f96">More...</a><br /></td></tr>
<tr class="separator:a880ae9f1e0a08f3c0cfe95f03b279f96"><td class="memSeparator" colspan="2"> </td></tr>
<tr class="memitem:a651019308fd148a1d1a84947d57e1679"><td class="memItemLeft" align="right" valign="top">void </td><td class="memItemRight" valign="bottom"><a class="el" href="classAbstractFifo.html#a651019308fd148a1d1a84947d57e1679">finishedRead</a> (int numRead) noexcept</td></tr>
<tr class="memdesc:a651019308fd148a1d1a84947d57e1679"><td class="mdescLeft"> </td><td class="mdescRight">Called after reading from the FIFO, to indicate that this many items have now been consumed. <a href="#a651019308fd148a1d1a84947d57e1679">More...</a><br /></td></tr>
<tr class="separator:a651019308fd148a1d1a84947d57e1679"><td class="memSeparator" colspan="2"> </td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Encapsulates the logic required to implement a lock-free FIFO. </p>
<p>This class handles the logic needed when building a single-reader, single-writer FIFO.</p>
<p>It doesn't actually hold any data itself, but your FIFO class can use one of these to manage its position and status when reading or writing to it.</p>
<p>To use it, you can call <a class="el" href="classAbstractFifo.html#a9f32996a86817773a7165be823f80c87" title="Returns the location within the buffer at which an incoming block of data should be written...">prepareToWrite()</a> to determine the position within your own buffer that an incoming block of data should be stored, and <a class="el" href="classAbstractFifo.html#a880ae9f1e0a08f3c0cfe95f03b279f96" title="Returns the location within the buffer from which the next block of data should be read...">prepareToRead()</a> to find out when the next outgoing block should be read from.</p>
<p>e.g. </p><div class="fragment"><div class="line"><span class="keyword">class </span>MyFifo</div><div class="line">{</div><div class="line"><span class="keyword">public</span>:</div><div class="line"> MyFifo() : abstractFifo (1024)</div><div class="line"> {</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> addToFifo (<span class="keyword">const</span> <span class="keywordtype">int</span>* someData, <span class="keywordtype">int</span> numItems)</div><div class="line"> {</div><div class="line"> <span class="keywordtype">int</span> start1, size1, start2, size2;</div><div class="line"> abstractFifo.prepareToWrite (numItems, start1, size1, start2, size2);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size1 > 0)</div><div class="line"> copySomeData (myBuffer + start1, someData, size1);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size2 > 0)</div><div class="line"> copySomeData (myBuffer + start2, someData + size1, size2);</div><div class="line"></div><div class="line"> abstractFifo.finishedWrite (size1 + size2);</div><div class="line"> }</div><div class="line"></div><div class="line"> <span class="keywordtype">void</span> readFromFifo (<span class="keywordtype">int</span>* someData, <span class="keywordtype">int</span> numItems)</div><div class="line"> {</div><div class="line"> <span class="keywordtype">int</span> start1, size1, start2, size2;</div><div class="line"> abstractFifo.prepareToRead (numItems, start1, size1, start2, size2);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size1 > 0)</div><div class="line"> copySomeData (someData, myBuffer + start1, size1);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size2 > 0)</div><div class="line"> copySomeData (someData + size1, myBuffer + start2, size2);</div><div class="line"></div><div class="line"> abstractFifo.finishedRead (size1 + size2);</div><div class="line"> }</div><div class="line"></div><div class="line"><span class="keyword">private</span>:</div><div class="line"> <a class="code" href="classAbstractFifo.html">AbstractFifo</a> abstractFifo;</div><div class="line"> <span class="keywordtype">int</span> myBuffer [1024];</div><div class="line">};</div></div><!-- fragment --> </div><h2 class="groupheader">Constructor & Destructor Documentation</h2>
<a id="accd680c366b4b8ca4f30ee8fb2b37b75"></a>
<h2 class="memtitle"><span class="permalink"><a href="#accd680c366b4b8ca4f30ee8fb2b37b75">§ </a></span>AbstractFifo()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">AbstractFifo::AbstractFifo </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>capacity</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Creates a FIFO to manage a buffer with the specified capacity. </p>
</div>
</div>
<a id="a81ff19ff8eed394e9f7aca08ae1e8e8d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a81ff19ff8eed394e9f7aca08ae1e8e8d">§ </a></span>~AbstractFifo()</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">AbstractFifo::~AbstractFifo </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</div><div class="memdoc">
<p>Destructor. </p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a7724b664c3aae6cbaad1a3821ccaf654"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a7724b664c3aae6cbaad1a3821ccaf654">§ </a></span>getTotalSize()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">int AbstractFifo::getTotalSize </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the total size of the buffer being managed. </p>
</div>
</div>
<a id="aeb68b5aec74f6511c76df390eda588ee"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aeb68b5aec74f6511c76df390eda588ee">§ </a></span>getFreeSpace()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">int AbstractFifo::getFreeSpace </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the number of items that can currently be added to the buffer without it overflowing. </p>
</div>
</div>
<a id="a39ab3206298a1aabb4412a6993b4023b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a39ab3206298a1aabb4412a6993b4023b">§ </a></span>getNumReady()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">int AbstractFifo::getNumReady </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the number of items that can currently be read from the buffer. </p>
</div>
</div>
<a id="a33ba0f93c22c9cc182f8fa78af07862f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a33ba0f93c22c9cc182f8fa78af07862f">§ </a></span>reset()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void AbstractFifo::reset </td>
<td>(</td>
<td class="paramname"></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Clears the buffer positions, so that it appears empty. </p>
</div>
</div>
<a id="a5ece35129a957c8783411de69b2542ec"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5ece35129a957c8783411de69b2542ec">§ </a></span>setTotalSize()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void AbstractFifo::setTotalSize </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>newSize</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Changes the buffer's total size. </p>
<p>Note that this isn't thread-safe, so don't call it if there's any danger that it might overlap with a call to any other method in this class! </p>
</div>
</div>
<a id="a9f32996a86817773a7165be823f80c87"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a9f32996a86817773a7165be823f80c87">§ </a></span>prepareToWrite()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void AbstractFifo::prepareToWrite </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>numToWrite</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>startIndex1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>blockSize1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>startIndex2</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>blockSize2</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the location within the buffer at which an incoming block of data should be written. </p>
<p>Because the section of data that you want to add to the buffer may overlap the end and wrap around to the start, two blocks within your buffer are returned, and you should copy your data into the first one, with any remaining data spilling over into the second.</p>
<p>If the number of items you ask for is too large to fit within the buffer's free space, then blockSize1 + blockSize2 may add up to a lower value than numToWrite. If this happens, you may decide to keep waiting and re-trying the method until there's enough space available.</p>
<p>After calling this method, if you choose to write your data into the blocks returned, you must call <a class="el" href="classAbstractFifo.html#a0daf6067beb737a4136e7e9d8f26bab0" title="Called after writing from the FIFO, to indicate that this many items have been added. ">finishedWrite()</a> to tell the FIFO how much data you actually added.</p>
<p>e.g. </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> addToFifo (<span class="keyword">const</span> <span class="keywordtype">int</span>* someData, <span class="keywordtype">int</span> numItems)</div><div class="line">{</div><div class="line"> <span class="keywordtype">int</span> start1, size1, start2, size2;</div><div class="line"> <a class="code" href="classAbstractFifo.html#a9f32996a86817773a7165be823f80c87">prepareToWrite</a> (numItems, start1, size1, start2, size2);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size1 > 0)</div><div class="line"> copySomeData (myBuffer + start1, someData, size1);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size2 > 0)</div><div class="line"> copySomeData (myBuffer + start2, someData + size1, size2);</div><div class="line"></div><div class="line"> <a class="code" href="classAbstractFifo.html#a0daf6067beb737a4136e7e9d8f26bab0">finishedWrite</a> (size1 + size2);</div><div class="line">}</div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">numToWrite</td><td>indicates how many items you'd like to add to the buffer </td></tr>
<tr><td class="paramname">startIndex1</td><td>on exit, this will contain the start index in your buffer at which your data should be written </td></tr>
<tr><td class="paramname">blockSize1</td><td>on exit, this indicates how many items can be written to the block starting at startIndex1 </td></tr>
<tr><td class="paramname">startIndex2</td><td>on exit, this will contain the start index in your buffer at which any data that didn't fit into the first block should be written </td></tr>
<tr><td class="paramname">blockSize2</td><td>on exit, this indicates how many items can be written to the block starting at startIndex2 </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classAbstractFifo.html#a0daf6067beb737a4136e7e9d8f26bab0" title="Called after writing from the FIFO, to indicate that this many items have been added. ">finishedWrite</a> </dd></dl>
</div>
</div>
<a id="a0daf6067beb737a4136e7e9d8f26bab0"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a0daf6067beb737a4136e7e9d8f26bab0">§ </a></span>finishedWrite()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void AbstractFifo::finishedWrite </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>numWritten</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Called after writing from the FIFO, to indicate that this many items have been added. </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classAbstractFifo.html#a9f32996a86817773a7165be823f80c87" title="Returns the location within the buffer at which an incoming block of data should be written...">prepareToWrite</a> </dd></dl>
</div>
</div>
<a id="a880ae9f1e0a08f3c0cfe95f03b279f96"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a880ae9f1e0a08f3c0cfe95f03b279f96">§ </a></span>prepareToRead()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void AbstractFifo::prepareToRead </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>numWanted</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>startIndex1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>blockSize1</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>startIndex2</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int & </td>
<td class="paramname"><em>blockSize2</em> </td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Returns the location within the buffer from which the next block of data should be read. </p>
<p>Because the section of data that you want to read from the buffer may overlap the end and wrap around to the start, two blocks within your buffer are returned, and you should read from both of them.</p>
<p>If the number of items you ask for is greater than the amount of data available, then blockSize1 + blockSize2 may add up to a lower value than numWanted. If this happens, you may decide to keep waiting and re-trying the method until there's enough data available.</p>
<p>After calling this method, if you choose to read the data, you must call <a class="el" href="classAbstractFifo.html#a651019308fd148a1d1a84947d57e1679" title="Called after reading from the FIFO, to indicate that this many items have now been consumed...">finishedRead()</a> to tell the FIFO how much data you have consumed.</p>
<p>e.g. </p><div class="fragment"><div class="line"><span class="keywordtype">void</span> readFromFifo (<span class="keywordtype">int</span>* someData, <span class="keywordtype">int</span> numItems)</div><div class="line">{</div><div class="line"> <span class="keywordtype">int</span> start1, size1, start2, size2;</div><div class="line"> <a class="code" href="classAbstractFifo.html#a880ae9f1e0a08f3c0cfe95f03b279f96">prepareToRead</a> (numSamples, start1, size1, start2, size2);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size1 > 0)</div><div class="line"> copySomeData (someData, myBuffer + start1, size1);</div><div class="line"></div><div class="line"> <span class="keywordflow">if</span> (size2 > 0)</div><div class="line"> copySomeData (someData + size1, myBuffer + start2, size2);</div><div class="line"></div><div class="line"> <a class="code" href="classAbstractFifo.html#a651019308fd148a1d1a84947d57e1679">finishedRead</a> (size1 + size2);</div><div class="line">}</div></div><!-- fragment --><dl class="params"><dt>Parameters</dt><dd>
<table class="params">
<tr><td class="paramname">numWanted</td><td>indicates how many items you'd like to add to the buffer </td></tr>
<tr><td class="paramname">startIndex1</td><td>on exit, this will contain the start index in your buffer at which your data should be written </td></tr>
<tr><td class="paramname">blockSize1</td><td>on exit, this indicates how many items can be written to the block starting at startIndex1 </td></tr>
<tr><td class="paramname">startIndex2</td><td>on exit, this will contain the start index in your buffer at which any data that didn't fit into the first block should be written </td></tr>
<tr><td class="paramname">blockSize2</td><td>on exit, this indicates how many items can be written to the block starting at startIndex2 </td></tr>
</table>
</dd>
</dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classAbstractFifo.html#a651019308fd148a1d1a84947d57e1679" title="Called after reading from the FIFO, to indicate that this many items have now been consumed...">finishedRead</a> </dd></dl>
</div>
</div>
<a id="a651019308fd148a1d1a84947d57e1679"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a651019308fd148a1d1a84947d57e1679">§ </a></span>finishedRead()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">void AbstractFifo::finishedRead </td>
<td>(</td>
<td class="paramtype">int </td>
<td class="paramname"><em>numRead</em></td><td>)</td>
<td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">noexcept</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p>Called after reading from the FIFO, to indicate that this many items have now been consumed. </p>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="classAbstractFifo.html#a880ae9f1e0a08f3c0cfe95f03b279f96" title="Returns the location within the buffer from which the next block of data should be read...">prepareToRead</a> </dd></dl>
</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li><a class="el" href="juce__AbstractFifo_8h.html">juce_AbstractFifo.h</a></li>
</ul>
</div><!-- contents -->
<hr class="footer"/>
<address class="footer"><small>All content © ROLI Ltd.</small></address><br/>
</body>
</html>
|