<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Allegro Crashes With USB Audio Attached and Set as Default...</title>
		<link>http://www.allegro.cc/forums/view/618563</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Wed, 10 Nov 2021 18:42:47 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Hi,</p><p>I&#39;ve been using Allegro 5 successfully on my Raspberry PI 4 (now Odroid C4) in a pure C project.  However, I recently added a USB sound bar, which is otherwise working fine on the system.  It shows up as &quot;Card 1&quot; with an &quot;aplay -l&quot;:</p><p>Odroid Root [AllegroTest] ==&gt; aplay -l<br />**** List of PLAYBACK Hardware Devices ****<br />card 0: ODROIDHDMI [ODROID-HDMI], device 0: SPDIF-dit-hifi dit-hifi-0 []<br />  Subdevices: 0/1<br />  Subdevice #0: subdevice #0<br />card 1: Device [USB2.0 Device], device 0: USB Audio [USB Audio]<br />  Subdevices: 1/1<br />  Subdevice #0: subdevice #0</p><p>In /etc/asound.config I changed &quot;card 0&quot; to &quot;card1&quot; to to force the USB to be default sound source with:</p><p>pcm.!default  {<br /> type hw card 1<br />}<br />ctl.!default {<br /> type hw card 1<br />}</p><p>amixer works fine with this setup:</p><p>amixer -c 1 cset numid=3 100</p><p>mplayer also works fine with this setup:</p><p>mplayer -ao alsa:device=default &quot;<a href="http://prem1.di.fm:80/vocaltrance_hi">http://prem1.di.fm:80/vocaltrance_hi</a></p><p>However Allegro always crashes hard with this setup.  Here is the function I am calling, gdb indicates the crash is happening at the line:</p><p>&quot;al_attach_sample_instance_to_mixer(sampleInstance, al_get_default_mixer() );&quot; </p><p>This is my function to setup and play my sounds (Sounds[ SoundsIndex ].SoundObject):</p><p>void PlaySound( unsigned int SoundsIndex )<br />{<br />ALLEGRO_SAMPLE_INSTANCE *sampleInstance = NULL;<br />   <br />   sampleInstance = al_create_sample_instance( Sounds[ SoundsIndex ].SoundObject );<br />   al_attach_sample_instance_to_mixer(sampleInstance, al_get_default_mixer() );<br />   al_play_sample_instance(sampleInstance);<br />   al_rest( Sounds[ SoundsIndex ].Length );<br />   al_destroy_sample_instance(sampleInstance);<br />}</p><p>I tried the latest version of the Allegro distribution.  I&#39;m really at a loss as what to try next to fix this.  I&#39;ve tried four different USB speakers, all behave the same.</p><p>If I set &quot;hw card 1&quot; to &quot;hw card 0&quot; in /etc/asound.conf, no allegro crashes, sound works through HDMI/SPDIF.</p><p>Please help, I&#39;m stumped...</p><p>Thank you,</p><p>Matt Dralle<br /><img src="http://www.allegro.cc/forums/smileys/huh.gif" alt="???" />
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matt Dralle)</author>
		<pubDate>Tue, 09 Nov 2021 10:40:35 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Can you get a full back-trace from GDB?<br />The crash in your code is in &quot;al_attach_sample_instance_to_mixer(sampleInstance, al_get_default_mixer() );&quot; but it&#39;s not clear from that, where in Allegro&#39;s internal code the crash might be.  <br />Pete
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Tue, 09 Nov 2021 16:24:48 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Here&#39;s the full gdb output at the crash including a &quot;where&quot;...</p><p>[New Thread 0x7faeffcd80 (LWP 61726)]</p><p>(leopard:61698): GLib-GIO-CRITICAL **: 11:12:52.009: g_dbus_proxy_new: assertion &#39;G_IS_DBUS_CONNECTION (connection)&#39; failed</p><p>Thread 6 &quot;leopard&quot; received signal SIGSEGV, Segmentation fault.<br />[Switching to Thread 0x7faeffcd80 (LWP 61726)]<br />al_attach_sample_instance_to_mixer (spl=spl@entry=0x7fa0000b60, mixer=0x0) at /usr/local/src/allegro/addons/audio/kcm_mixer.c:692<br />692     bool al_attach_sample_instance_to_mixer(ALLEGRO_SAMPLE_INSTANCE *spl,<br />(gdb) where<br />#0  al_attach_sample_instance_to_mixer (spl=spl@entry=0x7fa0000b60, mixer=0x0) at /usr/local/src/allegro/addons/audio/kcm_mixer.c:692<br />#1  0x0000005555570220 in PlaySound (SoundsIndex=1) at Sound.c:121<br />#2  PlaySound_Chimes (peram=&lt;optimized out&gt;) at Sound.c:149<br />#3  0x0000007fb763b4fc in start_thread (arg=0x7fffffef9f) at pthread_create.c:477<br />#4  0x0000007fb759467c in thread_start () at ../sysdeps/unix/sysv/linux/aarch64/clone.S:78<br />(gdb)
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matt Dralle)</author>
		<pubDate>Wed, 10 Nov 2021 01:16:04 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>If you look in the backtrace you can see that the pointer is null for the mixer you&#39;re attaching it to.</p><p>Look at the mixer creation it is returning null. Perhaps you passed it bad parameters.</p><p>al get default mixer will only return true if you&#39;ve created a hardware voice.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 10 Nov 2021 07:12:01 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Is the another call to init the mixer?</p><p>I&#39;m calling the following to setup Allegro up:</p><p>	al_init();<br />	al_install_audio();<br />	al_init_acodec_addon();<br />	al_reserve_samples( MAX_SOUND_COUNT );</p><p>In my &quot;al_attach_sample_instance_to_mixer(sampleInstance, al_get_default_mixer() );&quot;:</p><p>Why does the call to &quot;al_get_default_mixer()&quot; return NULL on the USB audio? Card 1 vs Card0</p><p>Thanks,</p><p>Matt
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matt Dralle)</author>
		<pubDate>Wed, 10 Nov 2021 09:16:18 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>I would start with the simplest possible program
</p><div class="source-code snippet"><div class="inner"><pre><span class="p">#include &lt;allegro5/allegro.h&gt;</span>
<span class="p">#include &lt;allegro5/allegro_audio.h&gt;</span>
<span class="p">#include &lt;stdio.h&gt;</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
  <a href="http://www.allegro.cc/manual/al_init"><span class="a">al_init</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/al_install_audio"><span class="a">al_install_audio</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.allegro.cc/manual/al_reserve_samples"><span class="a">al_reserve_samples</span></a><span class="k2">(</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span>
  <a href="http://www.delorie.com/djgpp/doc/libc/libc_624.html" target="_blank">printf</a><span class="k2">(</span><span class="s">"Default mixer: %p\n"</span>, <a href="http://www.allegro.cc/manual/al_get_default_mixer"><span class="a">al_get_default_mixer</span></a><span class="k2">(</span><span class="k2">)</span><span class="k2">)</span><span class="k2">;</span>
  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>
and also create an <span class="source-code">allegro5.cfg</span> in the same directory as the executable
</p><pre>
[trace]
level=debug
channels=all
</pre><p>
Can you confirm this reproduces the problem, default mixer is NULL for hw card 1 and not NULL for hw card 0? If you look at the file <span class="source-code">allegro.log</span> in both cases does it print anything helpful?
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Peter Hull)</author>
		<pubDate>Wed, 10 Nov 2021 18:37:09 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Check the return value of al_reserve_samples(...) . Step into the function and see where the voices and mixers are created.</p><p>Did you ever learn how to debug? Now is the time, my young padawan.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Edgar Reynaldo)</author>
		<pubDate>Wed, 10 Nov 2021 18:42:47 +0000</pubDate>
	</item>
</rss>
