This file is indexed.

/usr/share/doc/portaudio19-doc/doc/html/blocking_read_write.html is in portaudio19-doc 19+svn20140130-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
<!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.6"/>
<title>PortAudio: Blocking Read/Write Functions</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="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 style="padding-left: 0.5em;">
   <div id="projectname">PortAudio
   &#160;<span id="projectnumber">2.0</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.6 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Data&#160;Structures</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Blocking Read/Write Functions </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>PortAudio V19 adds a huge advance over previous versions with a feature called Blocking I/O. Although it may have lower performance that the callback method described earlier in this tutorial, blocking I/O is easier to understand and is, in some cases, more compatible with third party systems than the callback method. Most people starting audio programming also find Blocking I/O easier to learn.</p>
<p>Blocking I/O works in much the same way as the callback method except that instead of providing a function to provide (or consume) audio data, you must feed data to (or consume data from) PortAudio at regular intervals, usually inside a loop. The example below, excepted from patest_read_write_wire.c, shows how to open the default device, and pass data from its input to its output for a set period of time. Note that we use the default high latency values to help avoid underruns since we are usually reading and writing audio data from a relatively low priority thread, and there is usually extra buffering required to make blocking I/O work.</p>
<p>Note that not all API's implement Blocking I/O at this point, so for maximum portability or performance, you'll still want to use callbacks.</p>
<div class="fragment"><div class="line"><span class="comment">/* -- initialize PortAudio -- */</span></div>
<div class="line">err = <a class="code" href="portaudio_8h.html#abed859482d156622d9332dff9b2d89da">Pa_Initialize</a>();</div>
<div class="line"><span class="keywordflow">if</span>( err != paNoError ) <span class="keywordflow">goto</span> error;</div>
<div class="line"></div>
<div class="line"><span class="comment">/* -- setup input and output -- */</span></div>
<div class="line">inputParameters.device = <a class="code" href="portaudio_8h.html#abf9f2f82da95553d5adb929af670f74b">Pa_GetDefaultInputDevice</a>(); <span class="comment">/* default input device */</span></div>
<div class="line">inputParameters.channelCount = NUM_CHANNELS;</div>
<div class="line">inputParameters.sampleFormat = PA_SAMPLE_TYPE;</div>
<div class="line">inputParameters.suggestedLatency = <a class="code" href="portaudio_8h.html#ac7d8e091ffc1d1d4a035704660e117eb">Pa_GetDeviceInfo</a>( inputParameters.device )-&gt;<a class="code" href="structPaDeviceInfo.html#a4214826038fcaf374beb9816024e6c9f">defaultHighInputLatency</a> ;</div>
<div class="line">inputParameters.hostApiSpecificStreamInfo = NULL;</div>
<div class="line"></div>
<div class="line">outputParameters.device = <a class="code" href="portaudio_8h.html#adc955dfab007624000695c48d4f876dc">Pa_GetDefaultOutputDevice</a>(); <span class="comment">/* default output device */</span></div>
<div class="line">outputParameters.channelCount = NUM_CHANNELS;</div>
<div class="line">outputParameters.sampleFormat = PA_SAMPLE_TYPE;</div>
<div class="line">outputParameters.suggestedLatency = <a class="code" href="portaudio_8h.html#ac7d8e091ffc1d1d4a035704660e117eb">Pa_GetDeviceInfo</a>( outputParameters.device )-&gt;defaultHighOutputLatency;</div>
<div class="line">outputParameters.hostApiSpecificStreamInfo = NULL;</div>
<div class="line"></div>
<div class="line"><span class="comment">/* -- setup stream -- */</span></div>
<div class="line">err = <a class="code" href="portaudio_8h.html#a443ad16338191af364e3be988014cbbe">Pa_OpenStream</a>(</div>
<div class="line">          &amp;stream,</div>
<div class="line">          &amp;inputParameters,</div>
<div class="line">          &amp;outputParameters,</div>
<div class="line">          SAMPLE_RATE,</div>
<div class="line">          FRAMES_PER_BUFFER,</div>
<div class="line">          <a class="code" href="portaudio_8h.html#a837b8a81be3f7e36c96003e0d8dcec12">paClipOff</a>,      <span class="comment">/* we won&#39;t output out of range samples so don&#39;t bother clipping them */</span></div>
<div class="line">          NULL, <span class="comment">/* no callback, use blocking API */</span></div>
<div class="line">          NULL ); <span class="comment">/* no callback, so no callback userData */</span></div>
<div class="line"><span class="keywordflow">if</span>( err != paNoError ) <span class="keywordflow">goto</span> error;</div>
<div class="line"></div>
<div class="line"><span class="comment">/* -- start stream -- */</span></div>
<div class="line">err = <a class="code" href="portaudio_8h.html#a7432aadd26c40452da12fa99fc1a047b">Pa_StartStream</a>( stream );</div>
<div class="line"><span class="keywordflow">if</span>( err != paNoError ) <span class="keywordflow">goto</span> error;</div>
<div class="line">printf(<span class="stringliteral">&quot;Wire on. Will run one minute.\n&quot;</span>); fflush(stdout);</div>
<div class="line"></div>
<div class="line"><span class="comment">/* -- Here&#39;s the loop where we pass data from input to output -- */</span></div>
<div class="line"><span class="keywordflow">for</span>( i=0; i&lt;(60*SAMPLE_RATE)/FRAMES_PER_BUFFER; ++i )</div>
<div class="line">{</div>
<div class="line">   err = <a class="code" href="portaudio_8h.html#a075a6efb503a728213bdae24347ed27d">Pa_WriteStream</a>( stream, sampleBlock, FRAMES_PER_BUFFER );</div>
<div class="line">   <span class="keywordflow">if</span>( err ) <span class="keywordflow">goto</span> xrun;</div>
<div class="line">   err = <a class="code" href="portaudio_8h.html#a0b62d4b74b5d3d88368e9e4c0b8b2dc7">Pa_ReadStream</a>( stream, sampleBlock, FRAMES_PER_BUFFER );</div>
<div class="line">   <span class="keywordflow">if</span>( err ) <span class="keywordflow">goto</span> xrun;</div>
<div class="line">}</div>
<div class="line"><span class="comment">/* -- Now we stop the stream -- */</span></div>
<div class="line">err = <a class="code" href="portaudio_8h.html#af18dd60220251286c337631a855e38a0">Pa_StopStream</a>( stream );</div>
<div class="line"><span class="keywordflow">if</span>( err != paNoError ) <span class="keywordflow">goto</span> error;</div>
<div class="line"></div>
<div class="line"><span class="comment">/* -- don&#39;t forget to cleanup! -- */</span></div>
<div class="line">err = <a class="code" href="portaudio_8h.html#a92f56f88cbd14da0e8e03077e835d104">Pa_CloseStream</a>( stream );</div>
<div class="line"><span class="keywordflow">if</span>( err != paNoError ) <span class="keywordflow">goto</span> error;</div>
<div class="line"></div>
<div class="line"><a class="code" href="portaudio_8h.html#a0db317604e916e8bd6098e60e6237221">Pa_Terminate</a>();</div>
<div class="line"><span class="keywordflow">return</span> 0;</div>
</div><!-- fragment --><p>Previous: <a class="el" href="querying_devices.html">Enumerating and Querying PortAudio Devices</a> | Next: <a class="el" href="exploring.html">Exploring PortAudio</a> </p>
</div></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Sat Feb 15 2014 23:28:26 for PortAudio by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.6
</small></address>
</body>
</html>