  <?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.alsa-project.org/main/index.php?action=history&amp;feed=atom&amp;title=Test_latency.c</id>
	<title>Test latency.c - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.alsa-project.org/main/index.php?action=history&amp;feed=atom&amp;title=Test_latency.c"/>
	<link rel="alternate" type="text/html" href="https://www.alsa-project.org/main/index.php?title=Test_latency.c&amp;action=history"/>
	<updated>2026-04-10T17:03:27Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.0</generator>
	<entry>
		<id>https://www.alsa-project.org/main/index.php?title=Test_latency.c&amp;diff=6675&amp;oldid=prev</id>
		<title>Sdaau: /* Quick overview */ - added clarification about &quot;Trying latency ...&quot; line</title>
		<link rel="alternate" type="text/html" href="https://www.alsa-project.org/main/index.php?title=Test_latency.c&amp;diff=6675&amp;oldid=prev"/>
		<updated>2013-09-18T05:45:00Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Quick overview: &lt;/span&gt; - added clarification about &amp;quot;Trying latency ...&amp;quot; line&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 05:45, 18 September 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l253&quot;&gt;Line 253:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 253:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Starts a loop where (among other things) it:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;* Starts a loop where (among other things) it:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** shows the current latency value, using the &amp;lt;code&amp;gt;showlatency()&amp;lt;/code&amp;gt; function - which ultimately prints the &amp;quot;&amp;lt;i&amp;gt;Trying latency %li frames ...&amp;lt;/i&amp;gt;&amp;quot; line&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** shows the current latency value, using the &amp;lt;code&amp;gt;showlatency()&amp;lt;/code&amp;gt; function - which ultimately prints the &amp;quot;&amp;lt;i&amp;gt;Trying latency %li frames ...&amp;lt;/i&amp;gt;&amp;quot; line&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*** &amp;lt;small&gt;&amp;lt;i&gt;Note:&amp;lt;/i&gt; the &amp;lt;code&gt;showlatency(size_t latency)&amp;lt;/code&gt; function multiplies the &amp;lt;code&gt;latency&amp;lt;/code&gt; input argument by two (&amp;lt;code&gt;latency *= 2;&amp;lt;/code&gt;); so if the printout says &quot;&amp;lt;i&gt;Trying latency 128 frames ...&amp;lt;/i&gt;&quot;, that means that &amp;lt;code&gt;latency&amp;lt;/code&gt; parameter is actually 64&amp;lt;/small&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** calls [http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gac6c33091b049985baa6466e8fe93917e snd_pcm_link] on the capture and playback stream file descriptors, to have them &amp;quot;&amp;lt;i&amp;gt;start/stop/prepare in sync&amp;lt;/i&amp;gt;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** calls [http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gac6c33091b049985baa6466e8fe93917e snd_pcm_link] on the capture and playback stream file descriptors, to have them &amp;quot;&amp;lt;i&amp;gt;start/stop/prepare in sync&amp;lt;/i&amp;gt;&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** calls &amp;lt;code&amp;gt;snd_pcm_format_set_silence&amp;lt;/code&amp;gt;, and then&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** calls &amp;lt;code&amp;gt;snd_pcm_format_set_silence&amp;lt;/code&amp;gt;, and then&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** calls &amp;lt;code&amp;gt;writebuf(phandle, buffer, latency ...)&amp;lt;/code&amp;gt; '''''twice'''''&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** calls &amp;lt;code&amp;gt;writebuf(phandle, buffer, latency ...)&amp;lt;/code&amp;gt; '''''twice'''''&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*** &amp;lt;small&gt;&amp;lt;i&gt;Note:&amp;lt;/i&gt; since the value of the variable &amp;lt;code&gt;latency&amp;lt;/code&gt; is twice smaller than what the printout &quot;&amp;lt;i&gt;Trying latency %li frames ...&amp;lt;/i&gt;&quot; says - calling &amp;lt;code&gt;writebuf()&amp;lt;/code&gt; twice, means that we ultimately achieve the demanded latency, as shown on the printout.&amp;lt;/small&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** starts yet another &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt; loop, where:&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;** starts yet another &amp;lt;code&amp;gt;while&amp;lt;/code&amp;gt; loop, where:&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*** [http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gad4d53d58b996a7cd9a5cbf1710b90375 snd_pcm_wait] is called, if polling has been specified in the command line arguments;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;*** [http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gad4d53d58b996a7cd9a5cbf1710b90375 snd_pcm_wait] is called, if polling has been specified in the command line arguments;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l262&quot;&gt;Line 262:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 264:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See the source code for details of the &amp;lt;code&amp;gt;readbuf()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;writebuf()&amp;lt;/code&amp;gt; functions - which may involve loops of their own, but ultimately call &amp;lt;code&amp;gt;[http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#ga4c2c7bd26cf221268d59dc3bbeb9c048 snd_pcm_readi]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gabc748a500743713eafa960c7d104ca6f snd_pcm_writei]&amp;lt;/code&amp;gt;, respectively.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;See the source code for details of the &amp;lt;code&amp;gt;readbuf()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;writebuf()&amp;lt;/code&amp;gt; functions - which may involve loops of their own, but ultimately call &amp;lt;code&amp;gt;[http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#ga4c2c7bd26cf221268d59dc3bbeb9c048 snd_pcm_readi]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gabc748a500743713eafa960c7d104ca6f snd_pcm_writei]&amp;lt;/code&amp;gt;, respectively.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-added&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== '''Mailing list notes''' ===&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;=== '''Mailing list notes''' ===&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sdaau</name></author>
	</entry>
	<entry>
		<id>https://www.alsa-project.org/main/index.php?title=Test_latency.c&amp;diff=6674&amp;oldid=prev</id>
		<title>Sdaau: added quick overview section</title>
		<link rel="alternate" type="text/html" href="https://www.alsa-project.org/main/index.php?title=Test_latency.c&amp;diff=6674&amp;oldid=prev"/>
		<updated>2013-09-12T20:02:02Z</updated>

		<summary type="html">&lt;p&gt;added quick overview section&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 20:02, 12 September 2013&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l244&quot;&gt;Line 244:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 244:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hardware sync&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Hardware sync&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;=== '''Quick overview''' ===&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;In brief, the &amp;lt;code&gt;latency.c&amp;lt;/code&gt; program:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Parses the command line parameters/options, and sets the playback and capture stream properties according to them&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;* Starts a loop where (among other things) it:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;** shows the current latency value, using the &amp;lt;code&gt;showlatency()&amp;lt;/code&gt; function - which ultimately prints the &quot;&amp;lt;i&gt;Trying latency %li frames ...&amp;lt;/i&gt;&quot; line&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;** calls [http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gac6c33091b049985baa6466e8fe93917e snd_pcm_link] on the capture and playback stream file descriptors, to have them &quot;&amp;lt;i&gt;start/stop/prepare in sync&amp;lt;/i&gt;&quot;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;** calls &amp;lt;code&gt;snd_pcm_format_set_silence&amp;lt;/code&gt;, and then&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;** calls &amp;lt;code&gt;writebuf(phandle, buffer, latency ...)&amp;lt;/code&gt; '''''twice'''''&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;** starts yet another &amp;lt;code&gt;while&amp;lt;/code&gt; loop, where:&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*** [http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gad4d53d58b996a7cd9a5cbf1710b90375 snd_pcm_wait] is called, if polling has been specified in the command line arguments;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*** &amp;lt;code&gt;r = readbuf(chandle, buffer, latency, ...)&amp;lt;/code&gt; is called on the capture stream&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;*** &amp;lt;code&gt;writebuf(phandle, buffer, r, ...)&amp;lt;/code&gt; is called on the playback stream&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;See the source code for details of the &amp;lt;code&gt;readbuf()&amp;lt;/code&gt; and &amp;lt;code&gt;writebuf()&amp;lt;/code&gt; functions - which may involve loops of their own, but ultimately call &amp;lt;code&gt;[http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#ga4c2c7bd26cf221268d59dc3bbeb9c048 snd_pcm_readi]&amp;lt;/code&gt; and &amp;lt;code&gt;[http://www.alsa-project.org/alsa-doc/alsa-lib/group___p_c_m.html#gabc748a500743713eafa960c7d104ca6f snd_pcm_writei]&amp;lt;/code&gt;, respectively.&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Sdaau</name></author>
	</entry>
	<entry>
		<id>https://www.alsa-project.org/main/index.php?title=Test_latency.c&amp;diff=6671&amp;oldid=prev</id>
		<title>Sdaau: inited page</title>
		<link rel="alternate" type="text/html" href="https://www.alsa-project.org/main/index.php?title=Test_latency.c&amp;diff=6671&amp;oldid=prev"/>
		<updated>2013-08-18T11:06:52Z</updated>

		<summary type="html">&lt;p&gt;inited page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__FORCETOC__&lt;br /&gt;
== test latency.c ==&lt;br /&gt;
&lt;br /&gt;
Within &amp;lt;code&amp;gt;alsa-lib&amp;lt;/code&amp;gt;, there is a utility, [http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=test/latency.c; test/latency.c]  ([http://git.alsa-project.org/?p=alsa-lib.git;a=history;f=test/latency.c; history]), which performs a full-duplex test, where recorded (captured) data is played back.&lt;br /&gt;
&lt;br /&gt;
From &amp;lt;code&amp;gt;alsa-lib/test/latency.c&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
 *  Latency test program&lt;br /&gt;
 *&lt;br /&gt;
 *  This small demo program can be used for measuring latency between&lt;br /&gt;
 *  capture and playback. This latency is measured from driver (diff when&lt;br /&gt;
 *  playback and capture was started). Scheduler is set to SCHED_RR.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Building''' ===&lt;br /&gt;
&lt;br /&gt;
The name of the executable has to be passed explicitly to the &amp;lt;code&amp;gt;make&amp;lt;/code&amp;gt; command - via [http://thread.gmane.org/gmane.linux.alsa.devel/6746/focus=6750 Re: problem ragarding execution of Latency.c (alsa-devel)]:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
cd alsa-lib/test&lt;br /&gt;
make latency&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Options''' ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./latency -h&lt;br /&gt;
Usage: latency [OPTION]... [FILE]...&lt;br /&gt;
-h,--help      help&lt;br /&gt;
-P,--pdevice   playback device&lt;br /&gt;
-C,--cdevice   capture device&lt;br /&gt;
-m,--min       minimum latency in frames&lt;br /&gt;
-M,--max       maximum latency in frames&lt;br /&gt;
-F,--frames    frames to transfer&lt;br /&gt;
-f,--format    sample format&lt;br /&gt;
-c,--channels  channels&lt;br /&gt;
-r,--rate      rate&lt;br /&gt;
-B,--buffer    buffer size in frames&lt;br /&gt;
-E,--period    period size in frames&lt;br /&gt;
-s,--seconds   duration of test in seconds&lt;br /&gt;
-b,--block     block mode&lt;br /&gt;
-p,--poll      use poll (wait for event - reduces CPU usage)&lt;br /&gt;
-e,--effect    apply an effect (bandpass filter sweep)&lt;br /&gt;
Recognized sample formats are: S8 U8 S16_LE S16_BE U16_LE U16_BE S24_LE S24_BE U24_LE U24_BE S32_LE S32_BE U32_LE U32_BE FLOAT_LE FLOAT_BE FLOAT64_LE FLOAT64_BE IEC958_SUBFRAME_LE IEC958_SUBFRAME_BE MU_LAW A_LAW IMA_ADPCM MPEG GSM SPECIAL S24_3LE S24_3BE U24_3LE U24_3BE S20_3LE S20_3BE U20_3LE U20_3BE S18_3LE S18_3BE U18_3LE&lt;br /&gt;
&lt;br /&gt;
Tip #1 (usable latency with large periods, non-blocking mode, good CPU usage,&lt;br /&gt;
        superb xrun prevention):&lt;br /&gt;
  latency -m 8192 -M 8192 -t 1 -p&lt;br /&gt;
Tip #2 (superb latency, non-blocking mode, but heavy CPU usage):&lt;br /&gt;
  latency -m 128 -M 128&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
* The option &amp;lt;code&amp;gt;-F,--frames&amp;lt;/code&amp;gt; seems not to be handled anywhere in the code, and as such has no effect.&lt;br /&gt;
* The &amp;quot;Tip #1&amp;quot; refers to an option &amp;lt;code&amp;gt;-t&amp;lt;/code&amp;gt; which doesn't exist - however, it is likely a typo for the option &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; for duration in seconds&lt;br /&gt;
* The option &amp;lt;code&amp;gt;-s&amp;lt;/code&amp;gt; for duration in seconds is an integer, and the lowest it can be set is 1 second; default if not specified is 30 seconds&lt;br /&gt;
* Before 2012-08-08, there is a bug where the short options &amp;lt;code&amp;gt;-B&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-E&amp;lt;/code&amp;gt; are not recognized (&amp;quot;invalid option&amp;quot;) - but the long options &amp;lt;code&amp;gt;--buffer&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;--period&amp;lt;/code&amp;gt; still work even then.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Usage''' ===&lt;br /&gt;
&lt;br /&gt;
When called, the &amp;lt;code&amp;gt;test/latency.c&amp;lt;/code&amp;gt; program will attemp to set period/buffer sizes based on the latency entered, starting from &amp;lt;code&amp;gt;-m,--min&amp;lt;/code&amp;gt; option (or the default minimum latency = 64 if not specified). If the run succeeds without errors with that setting, the program exits; otherwise, the latency is increased, and the run repeated - if the run is succesful here, then program exits, else the process continues until the &amp;lt;code&amp;gt;-M,--max&amp;lt;/code&amp;gt; latency is reached.&lt;br /&gt;
&lt;br /&gt;
Example of successful run on Linux kernel 2.6.38 / ALSA 1.0.24.2 with HDA Intel onboard PCI soundcard:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ aplay -l&lt;br /&gt;
**** List of PLAYBACK Hardware Devices ****&lt;br /&gt;
card 0: Intel [HDA Intel], device 0: ALC269 Analog [ALC269 Analog]&lt;br /&gt;
  Subdevices: 1/1&lt;br /&gt;
  Subdevice #0: subdevice #0&lt;br /&gt;
&lt;br /&gt;
$ alsa-lib/test/latency -P hw:0,0 -C hw:0,0 -r 44100 -m 128 -M 128 -p -s 1&lt;br /&gt;
!!!Scheduler set to Round Robin with priority 99 FAILED!!!&lt;br /&gt;
Playback device is hw:0,0&lt;br /&gt;
Capture device is hw:0,0&lt;br /&gt;
Parameters are 44100Hz, S16_LE, 2 channels, non-blocking mode&lt;br /&gt;
Poll mode: yes&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 128, maximum latency = 128&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  period_time  : 1451&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 64&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 128&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  period_time  : 1451&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 64&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 128&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Trying latency 128 frames, 2902.494us, 2.902494ms (344.5312Hz)&lt;br /&gt;
Success&lt;br /&gt;
Playback:&lt;br /&gt;
*** frames = 44288 ***&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
  trigger_time: 84416.108859821&lt;br /&gt;
  tstamp      : 84417.110319083&lt;br /&gt;
  delay       : 80&lt;br /&gt;
  avail       : 48&lt;br /&gt;
  avail_max   : 120&lt;br /&gt;
Capture:&lt;br /&gt;
*** frames = 44160 ***&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
  trigger_time: 84416.108859821&lt;br /&gt;
  tstamp      : 84417.110439490&lt;br /&gt;
  delay       : 9&lt;br /&gt;
  avail       : 9&lt;br /&gt;
  avail_max   : 65&lt;br /&gt;
Maximum read: 64 frames&lt;br /&gt;
Maximum read latency: 1451.247us, 1.451247ms (689.0625Hz)&lt;br /&gt;
Hardware sync&lt;br /&gt;
Playback time = 84416.108859, Record time = 84416.108859, diff = 0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The message &amp;quot;&amp;lt;code&amp;gt;Scheduler set to Round Robin with priority 99 FAILED&amp;lt;/code&amp;gt;&amp;quot; can be avoided by running the program with &amp;lt;code&amp;gt;sudo&amp;lt;/code&amp;gt; (administrative privileges):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ sudo alsa-lib/test/latency -P hw:0,0 -C hw:0,0 -r 44100 -m 128 -M 128 -p -s 1&lt;br /&gt;
[sudo] password for user:&lt;br /&gt;
Scheduler set to Round Robin with priority 99...&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The program can also fail, if the streams experience an XRUN; in that case, if &amp;lt;code&amp;gt;-m&amp;lt;/code&amp;gt; is set to be equal to &amp;lt;code&amp;gt;-M&amp;lt;/code&amp;gt;, the program will immediately exit:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ alsa-lib/test/latency -P hw:0,0 -C hw:0,0 -r 44100 -m 128 -M 128 -p -s 1&lt;br /&gt;
!!!Scheduler set to Round Robin with priority 99 FAILED!!!&lt;br /&gt;
Playback device is hw:0,0&lt;br /&gt;
Capture device is hw:0,0&lt;br /&gt;
Parameters are 44100Hz, S16_LE, 2 channels, non-blocking mode&lt;br /&gt;
Poll mode: yes&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 128, maximum latency = 128&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  period_time  : 1451&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 64&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 128&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  period_time  : 1451&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 64&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 128&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Trying latency 128 frames, 2902.494us, 2.902494ms (344.5312Hz)&lt;br /&gt;
Failure&lt;br /&gt;
Playback:&lt;br /&gt;
*** frames = 38464 ***&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  trigger_time: 479.798093354&lt;br /&gt;
  tstamp      : 479.798185056&lt;br /&gt;
  delay       : 0&lt;br /&gt;
  avail       : 128&lt;br /&gt;
  avail_max   : 128&lt;br /&gt;
Capture:&lt;br /&gt;
*** frames = 38400 ***&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  trigger_time: 479.798093354&lt;br /&gt;
  tstamp      : 479.798361196&lt;br /&gt;
  delay       : 0&lt;br /&gt;
  avail       : 9&lt;br /&gt;
  avail_max   : 73&lt;br /&gt;
Maximum read: 64 frames&lt;br /&gt;
Maximum read latency: 1451.247us, 1.451247ms (689.0625Hz)&lt;br /&gt;
Hardware sync&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Mailing list notes''' ===&lt;br /&gt;
&lt;br /&gt;
[http://thread.gmane.org/gmane.linux.alsa.devel/17014 latency.c: some feature requests (alsa-devel)] (2004-11-28)&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; It looks like the playback runs 64 frames ahead of the capture.  Do you&lt;br /&gt;
&amp;gt; think this would be a problem from the application's perspective?&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&lt;br /&gt;
That's correct - it's the latency.&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; I also need the capture device interleaved and the playback device&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; noninterleaved.  latency.c does not support this at all, it just assumes&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; that all hardware supports interleaved format.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt; Use default device (-D default and -P default) which automatically&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt; uses available parameters.&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; This will not work because I need to use hw:0,3 for playback and hw:0,2&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt; for capture.&lt;br /&gt;
&amp;gt;&amp;gt;&lt;br /&gt;
&amp;gt;&amp;gt; -P plughw:0,3 -C plughw:0,2&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; [...] One other thing I noticed is that latency.c doesn't mmap.&lt;br /&gt;
&amp;gt; This would cause higher latencies compared to testing with JACK,&lt;br /&gt;
&amp;gt; correct?&lt;br /&gt;
&lt;br /&gt;
Yes, it's good point. Perhaps, the snd_pcm_mmap_readi/writei functions&lt;br /&gt;
should be used to optimize copying.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[http://thread.gmane.org/gmane.linux.alsa.devel/37367 latency.c and delay related questions (alsa-devel)] (2006-06-20)&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;gt; The current delay with &amp;quot;latency&amp;quot; is equal to a minimum (that depends&lt;br /&gt;
&amp;gt; on the sound card) plus *two* times the period time.  [...]&lt;br /&gt;
&lt;br /&gt;
Yes, it's correct. Basically, you cannot avoid double buffering, so the&lt;br /&gt;
total latency is:&lt;br /&gt;
&lt;br /&gt;
1) one capture period&lt;br /&gt;
2) one playback period (actually being played)&lt;br /&gt;
3) moved captured period to playback buffer (not counted)&lt;br /&gt;
&lt;br /&gt;
So the latency should be 2 * period plus a hw latency as you noted.&lt;br /&gt;
Everything is correct. Of course, you may get better latencies if you run&lt;br /&gt;
&amp;quot;busy loop&amp;quot; on not-loaded system and immediately put captured data to&lt;br /&gt;
playback stream, but it's not a correct behaviour in *nix.&lt;br /&gt;
&lt;br /&gt;
&amp;gt; * why is snd_pcm_link() mandatory? (no sound otherwise)&lt;br /&gt;
&lt;br /&gt;
It links playback and capture streams so only one start() is called. On&lt;br /&gt;
hardware which supports hardware syncing, the DMA operation is started at&lt;br /&gt;
same time for both stream.&lt;br /&gt;
&lt;br /&gt;
&amp;gt; * why two buffers of silence and not just one?&lt;br /&gt;
&lt;br /&gt;
You must wait one period to get data from the capture direction and then&lt;br /&gt;
you have exactly one period time to put these data to the playback. As I&lt;br /&gt;
said, you can get better results with busy-loop but it's bad&lt;br /&gt;
implementation (but if you have a spare dedicated machine without other&lt;br /&gt;
tasks, it might be an option).&lt;br /&gt;
&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
&amp;gt; [...] The linking of capture and playback devices&lt;br /&gt;
&amp;gt; explains everything; if I remove linking and use snd_pcm_start() on&lt;br /&gt;
&amp;gt; the playback device I get the expected behaviour.&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; Here is a little drawing (requires fixed font) to illustrate what you&lt;br /&gt;
&amp;gt; have said and what I have understood (useless for you but some people&lt;br /&gt;
&amp;gt; like me might find it useful).&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; When capture and playback devices are linked, the following happens:&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt;          +-------------------------&lt;br /&gt;
&amp;gt; Capture  | C0 | C1 | C2 | C3 | ...&lt;br /&gt;
&amp;gt;          +-------------------------&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt;          +-------------------------&lt;br /&gt;
&amp;gt; Playback | -- | -- | C0 | C1 | ...&lt;br /&gt;
&amp;gt;          +-------------------------&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; Capture and playback start simultaneously and so playback device needs&lt;br /&gt;
&amp;gt; something to play. When the first capture is finished, another is&lt;br /&gt;
&amp;gt; started. We would like to play the captured audio, but another&lt;br /&gt;
&amp;gt; playback has already started. Only after the latter is finished can&lt;br /&gt;
&amp;gt; the captured audio be played.&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; This explains why the playback device needs two buffers of silence.&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; The total delay is hw_delay + 2 * period&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Exactly. Well explained.&lt;br /&gt;
&lt;br /&gt;
&amp;gt; When the devices are not linked, we can start the playback device&lt;br /&gt;
&amp;gt; after the first buffer has been captured:&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt;          +-------------------------&lt;br /&gt;
&amp;gt; Capture  | C0 | C1 | C2 | C3 | ...&lt;br /&gt;
&amp;gt;          +-------------------------&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt;                  +-----------------&lt;br /&gt;
&amp;gt; Playback         | C0 | C1 | C2 | .&lt;br /&gt;
&amp;gt;                  +-----------------&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&amp;gt; Starting the playback device and copying data takes some time, so the&lt;br /&gt;
&amp;gt; total delay becomes hw_delay + 1 * period + start_delay + copy_delay.&lt;br /&gt;
&amp;gt; For large periods, with period &amp;gt; start_delay + copy_delay, this can&lt;br /&gt;
&amp;gt; lead to a lower latency, but who would use large periods for low&lt;br /&gt;
&amp;gt; latency?&lt;br /&gt;
&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Yes, this buffering schema is also possible, but note that the time window&lt;br /&gt;
for the data copy must satisfy the system scheduler requirements and&lt;br /&gt;
capabilities to get continous playback. In the &amp;quot;stream linked&amp;quot; case this&lt;br /&gt;
time window is exactly one period time.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Meaning of --buffer and --period''' ===&lt;br /&gt;
&lt;br /&gt;
Given the specific operation of the program outlined above, note that:&lt;br /&gt;
&lt;br /&gt;
* The latency parameter, derived from &amp;lt;code&amp;gt;-m/--min&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-M/--max&amp;lt;/code&amp;gt; parameters, ultimately translates to the PCM buffer_size&lt;br /&gt;
* Specifying &amp;lt;code&amp;gt;--buffer&amp;lt;/code&amp;gt; ultimately translates to the PCM period_size, and PCM buffer_size becomes 2x that - so we can consider it as a latency specification alternative to &amp;lt;code&amp;gt;-m/--min&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-M/--max&amp;lt;/code&amp;gt;&lt;br /&gt;
* Specifying &amp;lt;code&amp;gt;--period&amp;lt;/code&amp;gt; does override the PCM period_size, leaving the PCM buffer_size untouched; however, the program will typically exit with an error, if the period_size happens to be not equal to buffer_size/2 and smaller than buffer_size/2 (for values &amp;gt;= buffer_size/2, the engine automatically limits period_size to buffer_size/2)&lt;br /&gt;
&lt;br /&gt;
The easiest way to observe that is to patch/add the following &amp;lt;code&amp;gt;printf&amp;lt;/code&amp;gt; statements to the &amp;lt;code&amp;gt;setparams_bufsize&amp;lt;/code&amp;gt; function:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
int setparams_bufsize(...)&lt;br /&gt;
{&lt;br /&gt;
	int err;&lt;br /&gt;
	snd_pcm_uframes_t periodsize;&lt;br /&gt;
&lt;br /&gt;
	snd_pcm_hw_params_copy(params, tparams);&lt;br /&gt;
	periodsize = bufsize * 2;&lt;br /&gt;
	printf(&amp;quot; spbf: in bufsize:%li ; periodsize %li for %s\n&amp;quot;, bufsize, periodsize, id); //added&lt;br /&gt;
	err = snd_pcm_hw_params_set_buffer_size_near(handle, params, &amp;amp;periodsize);&lt;br /&gt;
	if (err &amp;lt; 0) {&lt;br /&gt;
		printf(&amp;quot;Unable to set buffer size %li for %s: %s\n&amp;quot;, bufsize * 2, id, snd_strerror(err));&lt;br /&gt;
		return err;&lt;br /&gt;
	}&lt;br /&gt;
	printf(&amp;quot;     ; set_buffer_size_near: %li for %s\n&amp;quot;, periodsize, id);                //added&lt;br /&gt;
	if (period_size &amp;gt; 0)&lt;br /&gt;
		periodsize = period_size;&lt;br /&gt;
	else&lt;br /&gt;
		periodsize /= 2;&lt;br /&gt;
	printf(&amp;quot;     ; now periodsize %li for %s\n&amp;quot;, periodsize, id);                       //added&lt;br /&gt;
	err = snd_pcm_hw_params_set_period_size_near(handle, params, &amp;amp;periodsize, 0);&lt;br /&gt;
	if (err &amp;lt; 0) {&lt;br /&gt;
		printf(&amp;quot;Unable to set period size %li for %s: %s\n&amp;quot;, periodsize, id, snd_strerror(err));&lt;br /&gt;
		return err;&lt;br /&gt;
	}&lt;br /&gt;
	printf(&amp;quot;     ; set_period_size_near: %li for %s\n&amp;quot;, periodsize, id);                //added&lt;br /&gt;
	return 0;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
With this change, we can now observe the buffer/period size calculations:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 64 -M 64 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 64, maximum latency = 64&lt;br /&gt;
 spbf: in bufsize:32 ; periodsize 64 for playback&lt;br /&gt;
     ; set_buffer_size_near: 64 for playback&lt;br /&gt;
     ; now periodsize 32 for playback&lt;br /&gt;
     ; set_period_size_near: 32 for playback&lt;br /&gt;
 spbf: in bufsize:32 ; periodsize 64 for capture&lt;br /&gt;
     ; set_buffer_size_near: 64 for capture&lt;br /&gt;
     ; now periodsize 32 for capture&lt;br /&gt;
     ; set_period_size_near: 32 for capture&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  buffer_size  : 64&lt;br /&gt;
  period_size  : 32&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  buffer_size  : 64&lt;br /&gt;
  period_size  : 32&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
Trying latency 64 frames, 1451.247us, 1.451247ms (689.0625Hz)&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
Maximum read: 32 frames&lt;br /&gt;
Maximum read latency: 725.624us, 0.725624ms (1378.1250Hz)&lt;br /&gt;
&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 128 -M 128 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 128, maximum latency = 128&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for playback&lt;br /&gt;
     ; set_buffer_size_near: 128 for playback&lt;br /&gt;
     ; now periodsize 64 for playback&lt;br /&gt;
     ; set_period_size_near: 64 for playback&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for capture&lt;br /&gt;
     ; set_buffer_size_near: 128 for capture&lt;br /&gt;
     ; now periodsize 64 for capture&lt;br /&gt;
     ; set_period_size_near: 64 for capture&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
Trying latency 128 frames, 2902.494us, 2.902494ms (344.5312Hz)&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
Maximum read: 64 frames&lt;br /&gt;
Maximum read latency: 1451.247us, 1.451247ms (689.0625Hz)&lt;br /&gt;
&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 256 -M 256 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 256, maximum latency = 256&lt;br /&gt;
 spbf: in bufsize:128 ; periodsize 256 for playback&lt;br /&gt;
     ; set_buffer_size_near: 256 for playback&lt;br /&gt;
     ; now periodsize 128 for playback&lt;br /&gt;
     ; set_period_size_near: 128 for playback&lt;br /&gt;
 spbf: in bufsize:128 ; periodsize 256 for capture&lt;br /&gt;
     ; set_buffer_size_near: 256 for capture&lt;br /&gt;
     ; now periodsize 128 for capture&lt;br /&gt;
     ; set_period_size_near: 128 for capture&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  buffer_size  : 256&lt;br /&gt;
  period_size  : 128&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  buffer_size  : 256&lt;br /&gt;
  period_size  : 128&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
Trying latency 256 frames, 5804.989us, 5.804989ms (172.2656Hz)&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
Maximum read: 128 frames&lt;br /&gt;
Maximum read latency: 2902.494us, 2.902494ms (344.5312Hz)&lt;br /&gt;
&lt;br /&gt;
# so, we have:&lt;br /&gt;
# -m 64 -M 64   -&amp;gt; buffer_size  : 64   -&amp;gt; Trying latency 64 frames&lt;br /&gt;
# -m 128 -M 128 -&amp;gt; buffer_size  : 128  -&amp;gt; Trying latency 128 frames&lt;br /&gt;
# -m 256 -M 256 -&amp;gt; buffer_size  : 256  -&amp;gt; Trying latency 256 frames&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 --buffer 128 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 64, maximum latency = 4096&lt;br /&gt;
 spbf: in bufsize:128 ; periodsize 256 for playback&lt;br /&gt;
     ; set_buffer_size_near: 256 for playback&lt;br /&gt;
     ; now periodsize 128 for playback&lt;br /&gt;
     ; set_period_size_near: 128 for playback&lt;br /&gt;
 spbf: in bufsize:128 ; periodsize 256 for capture&lt;br /&gt;
     ; set_buffer_size_near: 256 for capture&lt;br /&gt;
     ; now periodsize 128 for capture&lt;br /&gt;
     ; set_period_size_near: 128 for capture&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  buffer_size  : 256&lt;br /&gt;
  period_size  : 128&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  buffer_size  : 256&lt;br /&gt;
  period_size  : 128&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
Trying latency 256 frames, 5804.989us, 5.804989ms (172.2656Hz)&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
Maximum read: 128 frames&lt;br /&gt;
Maximum read latency: 2902.494us, 2.902494ms (344.5312Hz)&lt;br /&gt;
&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 --buffer 256 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 64, maximum latency = 4096&lt;br /&gt;
 spbf: in bufsize:256 ; periodsize 512 for playback&lt;br /&gt;
     ; set_buffer_size_near: 512 for playback&lt;br /&gt;
     ; now periodsize 256 for playback&lt;br /&gt;
     ; set_period_size_near: 256 for playback&lt;br /&gt;
 spbf: in bufsize:256 ; periodsize 512 for capture&lt;br /&gt;
     ; set_buffer_size_near: 512 for capture&lt;br /&gt;
     ; now periodsize 256 for capture&lt;br /&gt;
     ; set_period_size_near: 256 for capture&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  buffer_size  : 512&lt;br /&gt;
  period_size  : 256&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  buffer_size  : 512&lt;br /&gt;
  period_size  : 256&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
Trying latency 512 frames, 11609.977us, 11.609977ms (86.1328Hz)&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
  state       : RUNNING&lt;br /&gt;
Maximum read: 256 frames&lt;br /&gt;
Maximum read latency: 5804.989us, 5.804989ms (172.2656Hz)&lt;br /&gt;
&lt;br /&gt;
# so, we have:&lt;br /&gt;
# --buffer 128   -&amp;gt; buffer_size  : 256   -&amp;gt; Trying latency 256 frames&lt;br /&gt;
# --buffer 256   -&amp;gt; buffer_size  : 512   -&amp;gt; Trying latency 512 frames&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 128 -M 128 --period 64 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max\|support'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 128, maximum latency = 128&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for playback&lt;br /&gt;
     ; set_buffer_size_near: 128 for playback&lt;br /&gt;
     ; now periodsize 64 for playback&lt;br /&gt;
     ; set_period_size_near: 64 for playback&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for capture&lt;br /&gt;
     ; set_buffer_size_near: 128 for capture&lt;br /&gt;
     ; now periodsize 64 for capture&lt;br /&gt;
     ; set_period_size_near: 64 for capture&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
Trying latency 128 frames, 2902.494us, 2.902494ms (344.5312Hz)&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
Maximum read: 64 frames&lt;br /&gt;
Maximum read latency: 1451.247us, 1.451247ms (689.0625Hz)&lt;br /&gt;
&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 128 -M 128 --period 128 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max\|support'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 128, maximum latency = 128&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for playback&lt;br /&gt;
     ; set_buffer_size_near: 128 for playback&lt;br /&gt;
     ; now periodsize 128 for playback&lt;br /&gt;
     ; set_period_size_near: 64 for playback&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for capture&lt;br /&gt;
     ; set_buffer_size_near: 128 for capture&lt;br /&gt;
     ; now periodsize 128 for capture&lt;br /&gt;
     ; set_period_size_near: 64 for capture&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  buffer_size  : 128&lt;br /&gt;
  period_size  : 64&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
Trying latency 128 frames, 2902.494us, 2.902494ms (344.5312Hz)&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
Maximum read: 64 frames&lt;br /&gt;
Maximum read latency: 1451.247us, 1.451247ms (689.0625Hz)&lt;br /&gt;
&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 128 -M 128 --period 32 -p -s 1 | grep 'size\|Trying\|limit\|state\|stream\|Max\|support'&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 128, maximum latency = 128&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for playback&lt;br /&gt;
     ; set_buffer_size_near: 128 for playback&lt;br /&gt;
     ; now periodsize 32 for playback&lt;br /&gt;
     ; set_period_size_near: 32 for playback&lt;br /&gt;
 spbf: in bufsize:64 ; periodsize 128 for capture&lt;br /&gt;
     ; set_buffer_size_near: 128 for capture&lt;br /&gt;
     ; now periodsize 32 for capture&lt;br /&gt;
     ; set_period_size_near: 32 for capture&lt;br /&gt;
playback device does not support 2 periods per buffer&lt;br /&gt;
&lt;br /&gt;
# so, we have - for buffer_size/latency=128 (spec'd by -m 128 -M 128):&lt;br /&gt;
# --period 64   -&amp;gt; period_size  : 64    -&amp;gt; Trying latency 128 frames&lt;br /&gt;
# --period 128  -&amp;gt; period_size  : 64    -&amp;gt; Trying latency 128 frames&lt;br /&gt;
# --period 32   -&amp;gt; period_size  : 32    -&amp;gt; (error buffer_size != 2*period_size)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that the &amp;quot;device does not support 2 periods per buffer&amp;quot; message comes from a revision to &amp;lt;code&amp;gt;latency.c&amp;lt;/code&amp;gt; from 2011-04-20; earlier versions will exit, but not print a message.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== '''Algorithm locking''' ===&lt;br /&gt;
&lt;br /&gt;
Note that it is also possible to &amp;quot;lock&amp;quot; the program, especially if automatic latency increase is allowed by specifying different  &amp;lt;code&amp;gt;-m/--min&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;-M/--max&amp;lt;/code&amp;gt; options, and the very first run fails with an XRUN (which can happen often for small PCM period/buffer sizes).&lt;br /&gt;
&lt;br /&gt;
For instance, under Linux kernel 2.6.38 / ALSA 1.0.24.2, HDA Intel can typically lock with &amp;lt;code&amp;gt;-m 64 -M 128&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;-m 64 -M 128&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 64 -M 128 -p -s 1&lt;br /&gt;
!!!Scheduler set to Round Robin with priority 99 FAILED!!!&lt;br /&gt;
Playback device is hw:0,0&lt;br /&gt;
Capture device is hw:0,0&lt;br /&gt;
Parameters are 44100Hz, S16_LE, 2 channels, non-blocking mode&lt;br /&gt;
Poll mode: yes&lt;br /&gt;
Loop limit is 44100 frames, minimum latency = 64, maximum latency = 128&lt;br /&gt;
 spbf: in bufsize:32 ; periodsize 64 for playback&lt;br /&gt;
     ; set_buffer_size_near: 64 for playback&lt;br /&gt;
     ; now periodsize 32 for playback&lt;br /&gt;
     ; set_period_size_near: 32 for playback&lt;br /&gt;
 spbf: in bufsize:32 ; periodsize 64 for capture&lt;br /&gt;
     ; set_buffer_size_near: 64 for capture&lt;br /&gt;
     ; now periodsize 32 for capture&lt;br /&gt;
     ; set_period_size_near: 32 for capture&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 64&lt;br /&gt;
  period_size  : 32&lt;br /&gt;
  period_time  : 725&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 32&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 64&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 64&lt;br /&gt;
  period_size  : 32&lt;br /&gt;
  period_time  : 725&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 32&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 64&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Trying latency 64 frames, 1451.247us, 1.451247ms (689.0625Hz)&lt;br /&gt;
Failure&lt;br /&gt;
Playback:&lt;br /&gt;
*** frames = 64 ***&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  trigger_time: 7448.736132319&lt;br /&gt;
  tstamp      : 7448.736189100&lt;br /&gt;
  delay       : 0&lt;br /&gt;
  avail       : 81&lt;br /&gt;
  avail_max   : 81&lt;br /&gt;
Capture:&lt;br /&gt;
*** frames = 32 ***&lt;br /&gt;
  state       : XRUN&lt;br /&gt;
  trigger_time: 7448.736132319&lt;br /&gt;
  tstamp      : 7448.736301335&lt;br /&gt;
  delay       : 0&lt;br /&gt;
  avail       : 1&lt;br /&gt;
  avail_max   : 33&lt;br /&gt;
Maximum read: 32 frames&lt;br /&gt;
Maximum read latency: 725.624us, 0.725624ms (1378.1250Hz)&lt;br /&gt;
Hardware sync&lt;br /&gt;
 spbf: in bufsize:36 ; periodsize 72 for playback&lt;br /&gt;
     ; set_buffer_size_near: 64 for playback&lt;br /&gt;
     ; now periodsize 32 for playback&lt;br /&gt;
     ; set_period_size_near: 32 for playback&lt;br /&gt;
 spbf: in bufsize:36 ; periodsize 72 for capture&lt;br /&gt;
     ; set_buffer_size_near: 64 for capture&lt;br /&gt;
     ; now periodsize 32 for capture&lt;br /&gt;
     ; set_period_size_near: 32 for capture&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : PLAYBACK&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 64&lt;br /&gt;
  period_size  : 32&lt;br /&gt;
  period_time  : 725&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 32&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 64&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Hardware PCM card 0 'HDA Intel' device 0 subdevice 0&lt;br /&gt;
Its setup is:&lt;br /&gt;
  stream       : CAPTURE&lt;br /&gt;
  access       : RW_INTERLEAVED&lt;br /&gt;
  format       : S16_LE&lt;br /&gt;
  subformat    : STD&lt;br /&gt;
  channels     : 2&lt;br /&gt;
  rate         : 44100&lt;br /&gt;
  exact rate   : 44100 (44100/1)&lt;br /&gt;
  msbits       : 16&lt;br /&gt;
  buffer_size  : 64&lt;br /&gt;
  period_size  : 32&lt;br /&gt;
  period_time  : 725&lt;br /&gt;
  tstamp_mode  : NONE&lt;br /&gt;
  period_step  : 1&lt;br /&gt;
  avail_min    : 32&lt;br /&gt;
  period_event : 0&lt;br /&gt;
  start_threshold  : 2147483647&lt;br /&gt;
  stop_threshold   : 64&lt;br /&gt;
  silence_threshold: 0&lt;br /&gt;
  silence_size : 0&lt;br /&gt;
  boundary     : 1073741824&lt;br /&gt;
  appl_ptr     : 0&lt;br /&gt;
  hw_ptr       : 0&lt;br /&gt;
Trying latency 72 frames, 1632.653us, 1.632653ms (612.5000Hz)&lt;br /&gt;
^C&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, first the application is &amp;quot;Trying latency 64 frames&amp;quot;, experiences an XRUN there, and then repeats the process, this time &amp;quot;Trying latency 72 frames&amp;quot;. At this point, the application locks, and Ctrl-C needs to issued in the terminal to stop the application. Note that - in both cases - the engine decides on PCM buffer_size: 64, and period_size: 32 frames; regardless of what is specified as input latency.&lt;br /&gt;
&lt;br /&gt;
Note that if we piped the output to &amp;lt;code&amp;gt;grep&amp;lt;/code&amp;gt; also in the above example, similarly to previous examples - it is very likely that we would not observe the &amp;quot;Trying latency 72 frames ...&amp;quot; line.&lt;br /&gt;
&lt;br /&gt;
A quick debug would be to first run the program through &amp;lt;code&amp;gt;strace&amp;lt;/code&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ strace ./latency -P hw:0,0 -C hw:0,0 -r 44100 -m 64 -M 128 -p -s 1&lt;br /&gt;
...&lt;br /&gt;
ioctl(4, 0x400c4150, 0xbfc7f6c8)        = -1 EAGAIN (Resource temporarily unavailable)&lt;br /&gt;
ioctl(4, 0x400c4150, 0xbfc7f6c8)        = -1 EAGAIN (Resource temporarily unavailable)&lt;br /&gt;
ioctl(4, 0x400c4150, 0xbfc7f6c8)        = -1 EAGAIN (Resource temporarily unavailable)&lt;br /&gt;
ioctl(4, 0x400c4150, 0xbfc7f6c8)        = -1 EAGAIN (Resource temporarily unavailable)&lt;br /&gt;
^C--- SIGINT (Interrupt) @ 0 (0) ---&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... which tells us that the program gets stuck on an &amp;lt;code&amp;gt;ioctl&amp;lt;/code&amp;gt; system call, repeatedly trying to complete it (and again, Ctrl-C needs to issued in the terminal to stop the application).&lt;br /&gt;
&lt;br /&gt;
To see more precisely where this problem occurs, we can run the program in the &amp;lt;code&amp;gt;gdb&amp;lt;/code&amp;gt; debugger; wait for it to lock - and when it does, we can issue Ctrl-C to break into the program, and then issue &amp;lt;code&amp;gt;bt&amp;lt;/code&amp;gt; to obtain a backtrace.&lt;br /&gt;
&lt;br /&gt;
It should be noted here that &amp;lt;code&amp;gt;alsa-lib/test/latency&amp;lt;/code&amp;gt; is actually a shell script, which loads the libraries built from the specific &amp;lt;code&amp;gt;alsa-lib/&amp;lt;/code&amp;gt; source folder; however, for &amp;lt;code&amp;gt;gdb&amp;lt;/code&amp;gt;, we need the actual executable, which is typically in &amp;lt;code&amp;gt;alsa-lib/test/.libs/lt-latency&amp;lt;/code&amp;gt; &amp;lt;i&amp;gt;or&amp;lt;/i&amp;gt; &amp;lt;code&amp;gt;alsa-lib/test/.libs/latency&amp;lt;/code&amp;gt; (not sure why this name can vary; the &amp;lt;code&amp;gt;lt-&amp;lt;/code&amp;gt; prefix is likely due to &amp;lt;code&amp;gt;ltmain.sh (GNU libtool)&amp;lt;/code&amp;gt;).&lt;br /&gt;
&lt;br /&gt;
So, the &amp;lt;code&amp;gt;gdb&amp;lt;/code&amp;gt; session would look like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;small&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
$ gdb --args alsa-lib/test/.libs/latency -P hw:0,0 -C hw:0,0 -r 44100 -m 64 -M 128 -p -s 1&lt;br /&gt;
GNU gdb (GDB) 7.3.50.20110806-cvs&lt;br /&gt;
...&lt;br /&gt;
Reading symbols from /path/to/alsa-lib/test/.libs/latency...done.&lt;br /&gt;
(gdb) r&lt;br /&gt;
...&lt;br /&gt;
...&lt;br /&gt;
Trying latency 72 frames, 1632.653us, 1.632653ms (612.5000Hz)&lt;br /&gt;
^C&lt;br /&gt;
Program received signal SIGINT, Interrupt.&lt;br /&gt;
0x0012e416 in __kernel_vsyscall ()&lt;br /&gt;
(gdb) bt&lt;br /&gt;
#0  0x0012e416 in __kernel_vsyscall ()&lt;br /&gt;
#1  0x002c97c9 in ioctl () from /lib/i386-linux-gnu/libc.so.6&lt;br /&gt;
#2  0x00182890 in ?? () from /usr/lib/libasound.so.2&lt;br /&gt;
#3  0x00171ac4 in snd_pcm_writei () from /usr/lib/libasound.so.2&lt;br /&gt;
#4  0x0804a23b in writebuf (handle=0x8056ed8, buf=0x804e0b8 &amp;quot;&amp;quot;, len=8, frames=0xbffff1bc) at latency.c:383&lt;br /&gt;
#5  0x0804ab8d in main (argc=14, argv=0xbffff294) at latency.c:639&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/small&amp;gt;&lt;br /&gt;
&lt;br /&gt;
... which confirms that the failing &amp;lt;code&amp;gt;ioctl&amp;lt;/code&amp;gt; is due to a &amp;lt;code&amp;gt;snd_pcm_writei&amp;lt;/code&amp;gt; call.&lt;/div&gt;</summary>
		<author><name>Sdaau</name></author>
	</entry>
</feed>