<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Raspberry Pi - slightly delayed audio</title>
		<link>http://www.allegro.cc/forums/view/616682</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Mon, 30 Jan 2017 00:22:46 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>This is an issue which has been discussed a couple of times in the past, </p><p><a href="https://www.allegro.cc/forums/thread/616314">https://www.allegro.cc/forums/thread/616314</a></p><p><a href="https://www.raspberrypi.org/forums/viewtopic.php?f=33&amp;t=69266">https://www.raspberrypi.org/forums/viewtopic.php?f=33&amp;t=69266</a></p><p>...but I wanted to re-open to see if anyone has any new advice / recommendations / solutions.</p><p>I&#39;ve ported a game, mayhem <a href="https://github.com/martinohanlon/mayhem-pi">https://github.com/martinohanlon/mayhem-pi</a>, to allegro 5 on the Raspberry Pi and playing audio files are very slightly delayed, I would estimated at maybe 0.25 seconds.</p><p>I have tested on version 5.2.2[1] and the problem persists. I dont see the same problem on Windows and I didnt have the problem when running on Allegro 4.</p><p>Does anyone have any thoughts?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (martinohanlon)</author>
		<pubDate>Mon, 09 Jan 2017 03:16:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I imagine you want to play with the sound buffers, and make sure you&#39;re not using pulseaudio if you can help it. straight alsa, and reduce the sizes of the sound buffers.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 09 Jan 2017 03:19:02 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi Thomas,</p><p>Thanks a lot for the insight.  </p><p>Do you have any info on how I would use sound buffers and ensure that I am only using alsa?  I did a quick search of the manual and couldnt find much relevant.</p><p>Martin</p><p>---------------</p><p>Been doing a bit more digging....</p><p>I think I would do the following to set the driver alsa:</p><p>al_set_config_value(al_get_system_config(), &quot;audio&quot;, &quot;driver&quot;, &quot;alsa&quot;);
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (martinohanlon)</author>
		<pubDate>Mon, 09 Jan 2017 16:36:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You&#39;re right, this is something that&#39;s missing from the documentation. If you are using pulseaudio, try this:</p><p><span class="source-code"><a href="http://www.allegro.cc/manual/al_set_config_value"><span class="a">al_set_config_value</span></a><span class="k2">(</span><a href="http://www.allegro.cc/manual/al_get_system_config"><span class="a">al_get_system_config</span></a><span class="k2">(</span><span class="k2">)</span>, <span class="s">"pulseaudio"</span>, <span class="s">"buffer_size"</span>, <span class="s">"512"</span><span class="k2">)</span></span></p><p>The default is 1024. Setting it too small will cause overruns so instead of delay you get ugly noise.</p><p>[edit:] Make sure you call this before al_install_audio or it won&#39;t have any effect.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Mon, 09 Jan 2017 20:51:22 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That is quite the hack. Interesting enough to be noted in the manual for the audio_addon !
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (GullRaDriel)</author>
		<pubDate>Mon, 09 Jan 2017 20:53:54 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You can also use the config file <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Mon, 09 Jan 2017 22:22:28 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ok, so I have explicitly set the driver to alsa, with the same effect.  Any other ideas?</p><p>I tried using pulseaudio but I couldnt get any sound, even after starting pulseaudio, but I suspect that is a Pi setup issue as opposed to an allegro / pulseaudio issue.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (martinohanlon)</author>
		<pubDate>Tue, 10 Jan 2017 03:49:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>You want to look at the docs on the config file for the alsa audio driver, and tweak the buffers.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 10 Jan 2017 04:06:08 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The alsa driver only has a single setting &quot;device&quot; so there is no way to tweak anything there.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Tue, 10 Jan 2017 05:07:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><div class="quote_container"><div class="title"><a href="http://www.allegro.cc/forums/thread/616682/1027646#target">Elias</a> said:</div><div class="quote"><p>The alsa driver only has a single setting &quot;device&quot; so there is no way to tweak anything there.</p></div></div><p>Huh. Wonder what happened to all of that stuff...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Tue, 10 Jan 2017 10:29:34 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yeah I couldn&#39;t find anything in the allegro5.cfg config about buffers and alsa.</p><p>For others in the future, see the allegro5.cfg file in the source <a href="https://github.com/liballeg/allegro5/blob/master/allegro5.cfg">https://github.com/liballeg/allegro5/blob/master/allegro5.cfg</a> for a description.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (martinohanlon)</author>
		<pubDate>Wed, 11 Jan 2017 01:00:40 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I appologize for the wild goose chase. I guess I&#39;m too far out of the loop to be that helpful.</p><p>I had written the original alsa code, and it had the ability to change the alsa buffers, but i guess when it was ported, and re-ported to allegro 5, it was dumbed down.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Thomas Fjellstrom)</author>
		<pubDate>Wed, 11 Jan 2017 01:19:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I committed a <a href="https://github.com/liballeg/allegro5/commit/080d1c947e344988f406fbd1cf799ac80d857da3">change</a> to allow configuring the ALSA buffer size, but the default value is so low already I&#39;m a little skeptical it&#39;s actually at fault here. Either way, perhaps worth patching it in and trying it out.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 16 Jan 2017 23:08:50 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Where are we setting the fragment count? That also counts towards the delay from what I remember about alsa...
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Tue, 17 Jan 2017 00:47:11 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Thanks, Ill try the patch and report back.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (martinohanlon)</author>
		<pubDate>Wed, 18 Jan 2017 21:23:03 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>We might have to add a snd_pcm_hw_params_set_periods_near somewhere there as well. The ALSA latency is:</p><p>periodsize * <b>periods</b> / (rate * bytes_per_frame)</p><p>So it is a key parameter for low latency.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Elias)</author>
		<pubDate>Wed, 18 Jan 2017 21:57:25 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Bump. I got a Raspberry Pi myself, so once I get Allegro compiling I&#39;ll try to examine this.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Wed, 25 Jan 2017 22:00:59 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That would be excellent.</p><p>The compile of allegro on the Pi is pretty easy. I put some instructions on my blog they might be useful <img src="http://www.allegro.cc/forums/smileys/smiley.gif" alt=":)" /></p><p><a href="http://www.stuffaboutcode.com/2016/11/compile-allegro-5x-for-raspberry-pi.html">http://www.stuffaboutcode.com/2016/11/compile-allegro-5x-for-raspberry-pi.html</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (martinohanlon)</author>
		<pubDate>Wed, 25 Jan 2017 22:11:00 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I played around with this a bit. Indeed, if I set the audio driver to pulseaudio and start pulse audio via `pulseaudio --start` I get the 0.25 second delay. However, if I don&#39;t start pulseaudio and just use the default driver, everything seems to work fine. For me, the default driver appears to be OpenAL of all things... I tried also using the alsa and oss drivers, but those failed to initialize, so I&#39;ll have to investigate what&#39;s up with that.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (SiegeLord)</author>
		<pubDate>Mon, 30 Jan 2017 00:22:46 +0000</pubDate>
	</item>
</rss>
