Sophie

Sophie

distrib > Fedora > 18 > x86_64 > by-pkgid > 3f392fb1e8fac17e2e50bcefd6e09356 > files > 67

jack-audio-connection-kit-devel-1.9.9.5-1.fc18.i686.rpm

<!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"/>
<title>Jack2: Managing and determining latency</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">Jack2
   &#160;<span id="projectnumber">1.9.9</span>
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.1.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><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>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Managing and determining latency</div>  </div>
</div><!--header-->
<div class="contents">
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaf0f3028e1797eec7423dc10076586422"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__LatencyFunctions.html#gaf0f3028e1797eec7423dc10076586422">jack_port_set_latency</a> (jack_port_t *port, jack_nframes_t) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT</td></tr>
<tr class="memitem:gaf379bc0e88a6df6c4b7836db4b9382d7"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__LatencyFunctions.html#gaf379bc0e88a6df6c4b7836db4b9382d7">jack_port_get_latency_range</a> (jack_port_t *port, jack_latency_callback_mode_t mode, <a class="el" href="struct__jack__latency__range.html">jack_latency_range_t</a> *range) JACK_WEAK_EXPORT</td></tr>
<tr class="memitem:ga7a8f181fcec32945db7b8e06ee1ca94b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__LatencyFunctions.html#ga7a8f181fcec32945db7b8e06ee1ca94b">jack_port_set_latency_range</a> (jack_port_t *port, jack_latency_callback_mode_t mode, <a class="el" href="struct__jack__latency__range.html">jack_latency_range_t</a> *range) JACK_WEAK_EXPORT</td></tr>
<tr class="memitem:ga7dc2e095ab4b729dd4151c69ad29b537"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__LatencyFunctions.html#ga7dc2e095ab4b729dd4151c69ad29b537">jack_recompute_total_latencies</a> (jack_client_t *client) JACK_OPTIONAL_WEAK_EXPORT</td></tr>
<tr class="memitem:ga47fa957309f9b3111010284e10cc1de0"><td class="memItemLeft" align="right" valign="top">jack_nframes_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__LatencyFunctions.html#ga47fa957309f9b3111010284e10cc1de0">jack_port_get_latency</a> (jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT</td></tr>
<tr class="memitem:ga34105bfd538493c797f506ff7a46f488"><td class="memItemLeft" align="right" valign="top">jack_nframes_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__LatencyFunctions.html#ga34105bfd538493c797f506ff7a46f488">jack_port_get_total_latency</a> (jack_client_t *client, jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT</td></tr>
<tr class="memitem:ga56372ab81d673cc4a419fd04cd3bfb8a"><td class="memItemLeft" align="right" valign="top">int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__LatencyFunctions.html#ga56372ab81d673cc4a419fd04cd3bfb8a">jack_recompute_total_latency</a> (jack_client_t *, jack_port_t *port) JACK_OPTIONAL_WEAK_DEPRECATED_EXPORT</td></tr>
</table>
<a name="details" id="details"></a><h2>Detailed Description</h2>
<p>The purpose of JACK's latency API is to allow clients to easily answer two questions:</p>
<ul>
<li>How long has it been since the data read from a port arrived at the edge of the JACK graph (either via a physical port or being synthesized from scratch)?</li>
</ul>
<ul>
<li>How long will it be before the data written to a port arrives at the edge of a JACK graph?</li>
</ul>
<p>To help answering these two questions, all JACK ports have two latency values associated with them, both measured in frames:</p>
<p><b>capture latency</b>: how long since the data read from the buffer of a port arrived at at a port marked with JackPortIsTerminal. The data will have come from the "outside
                 world" if the terminal port is also marked with JackPortIsPhysical, or will have been synthesized by the client that owns the terminal port.</p>
<p><b>playback latency</b>: how long until the data written to the buffer of port will reach a port marked with JackPortIsTerminal.</p>
<p>Both latencies might potentially have more than one value because there may be multiple pathways to/from a given port and a terminal port. Latency is therefore generally expressed a min/max pair.</p>
<p>In most common setups, the minimum and maximum latency are the same, but this design accomodates more complex routing, and allows applications (and thus users) to detect cases where routing is creating an anomalous situation that may either need fixing or more sophisticated handling by clients that care about latency.</p>
<p>See also jack_set_latency_callback for details on how clients that add latency to the signal path should interact with JACK to ensure that the correct latency figures are used. </p>
<h2>Function Documentation</h2>
<a class="anchor" id="gaf0f3028e1797eec7423dc10076586422"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void jack_port_set_latency </td>
          <td>(</td>
          <td class="paramtype">jack_port_t *&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">jack_nframes_t&#160;</td>
          <td class="paramname">&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The port latency is zero by default. Clients that control physical hardware with non-zero latency should call this to set the latency to its correct value. Note that the value should include any systemic latency present "outside" the physical hardware controlled by the client. For example, for a client controlling a digital audio interface connected to an external digital converter, the latency setting should include both buffering by the audio interface <em>and</em> the converter.</p>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000008">Deprecated:</a></b></dt><dd>This method will be removed in the next major release of JACK. It should not be used in new code, and should be replaced by a latency callback that calls <a class="el" href="group__LatencyFunctions.html#ga7a8f181fcec32945db7b8e06ee1ca94b">jack_port_set_latency_range()</a>. </dd></dl>

</div>
</div>
<a class="anchor" id="gaf379bc0e88a6df6c4b7836db4b9382d7"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void jack_port_get_latency_range </td>
          <td>(</td>
          <td class="paramtype">jack_port_t *&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">jack_latency_callback_mode_t&#160;</td>
          <td class="paramname"><em>mode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct__jack__latency__range.html">jack_latency_range_t</a> *&#160;</td>
          <td class="paramname"><em>range</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>return the latency range defined by <em>mode</em> for <em>port</em>, in frames.</p>
<p>See <a class="el" href="group__LatencyFunctions.html">Managing and determining latency</a> for the definition of each latency value.</p>
<p>This is normally used in the LatencyCallback. and therefor safe to execute from callbacks. </p>

</div>
</div>
<a class="anchor" id="ga7a8f181fcec32945db7b8e06ee1ca94b"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void jack_port_set_latency_range </td>
          <td>(</td>
          <td class="paramtype">jack_port_t *&#160;</td>
          <td class="paramname"><em>port</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">jack_latency_callback_mode_t&#160;</td>
          <td class="paramname"><em>mode</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="struct__jack__latency__range.html">jack_latency_range_t</a> *&#160;</td>
          <td class="paramname"><em>range</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>set the minimum and maximum latencies defined by <em>mode</em> for <em>port</em>, in frames.</p>
<p>See <a class="el" href="group__LatencyFunctions.html">Managing and determining latency</a> for the definition of each latency value.</p>
<p>This function should ONLY be used inside a latency callback. The client should determine the current value of the latency using <a class="el" href="group__LatencyFunctions.html#gaf379bc0e88a6df6c4b7836db4b9382d7">jack_port_get_latency_range()</a> (called using the same mode as <em>mode</em>) and then add some number of frames to that reflects latency added by the client.</p>
<p>How much latency a client adds will vary dramatically. For most clients, the answer is zero and there is no reason for them to register a latency callback and thus they should never call this function.</p>
<p>More complex clients that take an input signal, transform it in some way and output the result but not during the same process() callback will generally know a single constant value to add to the value returned by <a class="el" href="group__LatencyFunctions.html#gaf379bc0e88a6df6c4b7836db4b9382d7">jack_port_get_latency_range()</a>.</p>
<p>Such clients would register a latency callback (see jack_set_latency_callback) and must know what input ports feed which output ports as part of their internal state. Their latency callback will update the ports' latency values appropriately.</p>
<p>A pseudo-code example will help. The <em>mode</em> argument to the latency callback will determine whether playback or capture latency is being set. The callback will use <a class="el" href="group__LatencyFunctions.html#ga7a8f181fcec32945db7b8e06ee1ca94b">jack_port_set_latency_range()</a> as follows:</p>
<div class="fragment"><div class="line"><a class="code" href="struct__jack__latency__range.html">jack_latency_range_t</a> range;</div>
<div class="line"><span class="keywordflow">if</span> (mode == JackPlaybackLatency) {</div>
<div class="line"> <span class="keywordflow">foreach</span> input_port in (all <span class="keyword">self</span>-registered port) {</div>
<div class="line">  <a class="code" href="group__LatencyFunctions.html#gaf379bc0e88a6df6c4b7836db4b9382d7">jack_port_get_latency_range</a> (port_feeding_input_port, JackPlaybackLatency, &amp;range);</div>
<div class="line">  range.<a class="code" href="struct__jack__latency__range.html#ab357b9064e2793e29755f5a6b550c3f2">min</a> += min_delay_added_as_signal_flows_from port_feeding to input_port;</div>
<div class="line">  range.<a class="code" href="struct__jack__latency__range.html#a27a00059e59b8f7790d0479f8748a68f">max</a> += max_delay_added_as_signal_flows_from port_feeding to input_port;</div>
<div class="line">  <a class="code" href="group__LatencyFunctions.html#ga7a8f181fcec32945db7b8e06ee1ca94b">jack_port_set_latency_range</a> (input_port, JackPlaybackLatency, &amp;range);</div>
<div class="line"> }</div>
<div class="line">} <span class="keywordflow">else</span> <span class="keywordflow">if</span> (mode == JackCaptureLatency) {</div>
<div class="line"> <span class="keywordflow">foreach</span> output_port in (all <span class="keyword">self</span>-registered port) {</div>
<div class="line">  <a class="code" href="group__LatencyFunctions.html#gaf379bc0e88a6df6c4b7836db4b9382d7">jack_port_get_latency_range</a> (port_fed_by_output_port, JackCaptureLatency, &amp;range);</div>
<div class="line">  range.<a class="code" href="struct__jack__latency__range.html#ab357b9064e2793e29755f5a6b550c3f2">min</a> += min_delay_added_as_signal_flows_from_output_port_to_fed_by_port;</div>
<div class="line">  range.<a class="code" href="struct__jack__latency__range.html#a27a00059e59b8f7790d0479f8748a68f">max</a> += max_delay_added_as_signal_flows_from_output_port_to_fed_by_port;</div>
<div class="line">  <a class="code" href="group__LatencyFunctions.html#ga7a8f181fcec32945db7b8e06ee1ca94b">jack_port_set_latency_range</a> (output_port, JackCaptureLatency, &amp;range);</div>
<div class="line"> }</div>
<div class="line">}</div>
</div><!-- fragment --><p>In this relatively simple pseudo-code example, it is assumed that each input port or output is connected to only 1 output or input port respectively.</p>
<p>If a port is connected to more than 1 other port, then the range.min and range.max values passed to <a class="el" href="group__LatencyFunctions.html#ga7a8f181fcec32945db7b8e06ee1ca94b">jack_port_set_latency_range()</a> should reflect the minimum and maximum values across all connected ports.</p>
<p>See the description of jack_set_latency_callback for more information. </p>

</div>
</div>
<a class="anchor" id="ga7dc2e095ab4b729dd4151c69ad29b537"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int jack_recompute_total_latencies </td>
          <td>(</td>
          <td class="paramtype">jack_client_t *&#160;</td>
          <td class="paramname"><em>client</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Request a complete recomputation of all port latencies. This can be called by a client that has just changed the internal latency of its port using jack_port_set_latency and wants to ensure that all signal pathways in the graph are updated with respect to the values that will be returned by jack_port_get_total_latency. It allows a client to change multiple port latencies without triggering a recompute for each change.</p>
<dl class="section return"><dt>Returns</dt><dd>zero for successful execution of the request. non-zero otherwise. </dd></dl>

</div>
</div>
<a class="anchor" id="ga47fa957309f9b3111010284e10cc1de0"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">jack_nframes_t jack_port_get_latency </td>
          <td>(</td>
          <td class="paramtype">jack_port_t *&#160;</td>
          <td class="paramname"><em>port</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">
<dl class="section return"><dt>Returns</dt><dd>the time (in frames) between data being available or delivered at/to a port, and the time at which it arrived at or is delivered to the "other side" of the port. E.g. for a physical audio output port, this is the time between writing to the port and when the signal will leave the connector. For a physical audio input port, this is the time between the sound arriving at the connector and the corresponding frames being readable from the port.</dd></dl>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000009">Deprecated:</a></b></dt><dd>This method will be removed in the next major release of JACK. It should not be used in new code, and should be replaced by <a class="el" href="group__LatencyFunctions.html#gaf379bc0e88a6df6c4b7836db4b9382d7">jack_port_get_latency_range()</a> in any existing use cases. </dd></dl>

</div>
</div>
<a class="anchor" id="ga34105bfd538493c797f506ff7a46f488"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">jack_nframes_t jack_port_get_total_latency </td>
          <td>(</td>
          <td class="paramtype">jack_client_t *&#160;</td>
          <td class="paramname"><em>client</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">jack_port_t *&#160;</td>
          <td class="paramname"><em>port</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>The maximum of the sum of the latencies in every connection path that can be drawn between the port and other ports with the JackPortIsTerminal flag set.</p>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000010">Deprecated:</a></b></dt><dd>This method will be removed in the next major release of JACK. It should not be used in new code, and should be replaced by <a class="el" href="group__LatencyFunctions.html#gaf379bc0e88a6df6c4b7836db4b9382d7">jack_port_get_latency_range()</a> in any existing use cases. </dd></dl>

</div>
</div>
<a class="anchor" id="ga56372ab81d673cc4a419fd04cd3bfb8a"></a>
<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">int jack_recompute_total_latency </td>
          <td>(</td>
          <td class="paramtype">jack_client_t *&#160;</td>
          <td class="paramname">, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">jack_port_t *&#160;</td>
          <td class="paramname"><em>port</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">
<p>Request a complete recomputation of a port's total latency. This can be called by a client that has just changed the internal latency of its port using jack_port_set_latency and wants to ensure that all signal pathways in the graph are updated with respect to the values that will be returned by jack_port_get_total_latency.</p>
<dl class="section return"><dt>Returns</dt><dd>zero for successful execution of the request. non-zero otherwise.</dd></dl>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000011">Deprecated:</a></b></dt><dd>This method will be removed in the next major release of JACK. It should not be used in new code, and should be replaced by <a class="el" href="group__LatencyFunctions.html#ga7dc2e095ab4b729dd4151c69ad29b537">jack_recompute_total_latencies()</a> in any existing use cases. </dd></dl>

</div>
</div>
</div><!-- contents -->
<hr size="1"><address style="text-align: right;"><small>
Generated for Jack2 by <a href="http://www.doxygen.org/
index.html"><img src="doxygen.png" alt="doxygen" align="middle" border="0"></a>
1.8.1.2</small></address>
</body>
</html>