al_install_audio fails everytime

Hi. As the topic says I am having difficulties with al_install_audio(). I am compiling with gcc from Ubuntu 12.04 on a Dell Inspiron 1525 laptop and using Allegro-5.0. I have never had any issues with my audio driver in the past, but there seems to be one now.

Audio device: Intel Corporation 82801H (ICH8 Family) HD Audio Controller (rev 02).

When trying al_install_audio in a simple sample program I get this error:
run: /home/shawn/Game-Dev/allegro/addons/audio/kcm_voice.c:83: al_create_voice: Assertion `_al_kcm_driver' failed.
Aborted (core dumped)

With local debugging I know that it is definitely the allegro function listed above causing the problem. I had one idea to throw a breakpoint in the audio.c or kcm_voice.c file and try to see more specifically where the issue is occurring, but I cannot get that file to compile. Does anyone know what files I need to link in order to compile addons/audio/audio.c or addons/audio/kcm_voice.c?

Even better, has anyone else had/solved a similar problem with al_install_audio?

Any help would be much appreciated! Thank you.

Edgar Reynaldo

Which version of allegro 5.0 are you using? 5.0.10 is the latest 'stable' and 5.1.8 is the latest 'unstable' version. Did you call al_init()? The crash you are talking about is inside 'al_create_voice' if I read the code across versions correctly. Does al_install_audio return false, or does it crash?


As for building audio.c, you should just let cmake and your compiler compile it for you. (Ie, build from source)


If you are using the Dubug version of the allegro library precompiled, you could also debug directly into Allegro source without the need to compile from said source.


As for version, I used git to clone the latest version a few weeks ago which I believe gave me 5.0.11. But before building I did a git checkout 5.0 so I thought I was simply using the 5.0 version?

al_init had been called prior to al_install_audio and the latter returns false. I believe the error I posted above is due to al_init_acodec trying to run with the audio not installed properly. (Since then I added a check that returns -1 if audio is not installed properly)

Sorry this next question even sounds stupid to me, but how would I go about debugging any of the allegro files? I'm fairly new to gdb and large software projects in general.

Thanks for the help guys.

Edgar Reynaldo

If al_install_audio is returning false, then allegro.log might have something to say about why. Link to the debugging version of Allegro and then run your program and it will create a file called allegro.log. Post that.

Some common gdb commands :

1gdb myProgram.exe 2 3... 4 5>run 6// program runs 7 8// crashes here 9>backtrace 10// backtrace of stack shown here, this is what we need 11 12// select frame N (0-whatever) 13>frame N 14 15// show all local variables inside the first through nth frame 16>backtrace N full 17 18// show threads 19>info threads 20 21// break inside main.cpp on line 30 22>break main.cpp:30 23// this can be used to set breakpoints inside allegro routines as well with the same syntax 24 25// quit 26>quit


Backtrace after program crashes:

1Program received signal SIGABRT, Aborted. 20x00132416 in __kernel_vsyscall () 3(gdb) backtrace 4#0 0x00132416 in __kernel_vsyscall () 5#1 0x002621df in raise () from /lib/i386-linux-gnu/ 6#2 0x00265825 in abort () from /lib/i386-linux-gnu/ 7#3 0x0025b085 in ?? () from /lib/i386-linux-gnu/ 8#4 0x0025b137 in __assert_fail () from /lib/i386-linux-gnu/ 9#5 0x00226865 in al_create_voice (freq=44100, 10 depth=ALLEGRO_AUDIO_DEPTH_INT16, chan_conf=ALLEGRO_CHANNEL_CONF_2) 11 at /home/shawn/Game-Dev/allegro/addons/audio/kcm_voice.c:83 12#6 0x00223fb0 in create_default_mixer () 13 at /home/shawn/Game-Dev/allegro/addons/audio/kcm_sample.c:86 14#7 al_restore_default_mixer () 15 at /home/shawn/Game-Dev/allegro/addons/audio/kcm_sample.c:303 16#8 0x00224125 in al_reserve_samples (reserve_samples=0) 17 at /home/shawn/Game-Dev/allegro/addons/audio/kcm_sample.c:212 18#9 0x08048b74 in main () at samples.c:56

This is a very simple program I am running to figure the audio out before I add it to a game I am creating. Display, event queue, and sample just to test the audio. Let me know if this backtrace is able to be diagnosed at all or if you need more. I am constantly searching online (although this is the only place where anyone seems to know anything about allegro). Also trying things on my own but I am quite stumped.

Thanks again

Edgar Reynaldo

If al_install_audio is returning false, there's no point in trying to do anything with the audio. You need to fix that first. Did you link against the debugging versions of allegro and then look at allegro.log? Post it here.


Took me a minute but I did as you said and this is the allegro.log:

1oss I oss.c:266 oss_open [ 0.54454] OSS4 support not compiled in. Skipping OSS4 probe. 2oss E oss.c:215 oss_open_ver3 [ 0.54460] No '/dev/dsp' device available in your system. 3oss E oss.c:217 oss_open_ver3 [ 0.54461] Perhaps Open Sound System is not installed or running. 4oss E oss.c:268 oss_open [ 0.54462] Failed to init OSS. 5audio E audio.c:23 _al_set_error [ 0.54463] No audio driver can be used. (error code: 1)

I tried changing the driver in my allegro5.cfg to all other options with no success. This log was produced with driver=default.

BTW, I am compiling like this to link with debug:
gcc whatever.c -lallegro -lallegro_audio-debug -lallegro_acodec-debug

Is this the correct way of doing so? Also do I add -debug to every library I link with for a program using a lot more addons?


If you are on Ubuntu, you most likely want to install libpulse-dev then rerun cmake so it can pick up pulse audio.

Thomas Fjellstrom

Did it try ALSA support at all (you need libasound-dev for that)? But yeah, if you have ubuntu or another modernish distro you need libpulse-dev.


I went ahead and installed libpulse-dev and (at first al_install_audio is still returning false, but now isn't!) my allegro.log has changed to this:

1PulseAudio D pulseaudio.c:119 pulseaudio_open [ 0.68896] PA_CONTEXT_READY 2audio I audio.c:275 do_install_audio [ 0.68959] Using PulseAudio driver 3audio D kcm_mixer.c:121 _al_rechannel_matrix [ 0.70185] sample matrix: 4audio D kcm_mixer.c:127 _al_rechannel_matrix [ 0.70189] 5audio D kcm_mixer.c:127 _al_rechannel_matrix [ 0.70190]

which doesn't look very suspicious to me. I installed libpulse-dev and libasound-dev and at first things seemed the same but everything initializes just fine now. With that said, I'm sure its something stupid I must be doing since al_play_sample is making me crash. I've tried with an ogg vorbis file and .flac but neither work. Both are definitely in the same directory as my source and spelled as they are when I load them.

Here is my skeleton of a program that I thought would easily ensure my audio works:

1#include <stdio.h> 2#include <allegro5/allegro.h> 3#include <allegro5/allegro_audio.h> 4#include <allegro5/allegro_acodec.h> 5 6int main() 7{ 8 int width = 640; 9 int height = 480; 10 11 bool done = false; 12 13 ALLEGRO_DISPLAY *display = NULL; 14 ALLEGRO_EVENT_QUEUE *event_queue = NULL; 15 ALLEGRO_SAMPLE *sample = NULL; 16 17 if(!al_init()) 18 { 19 fprintf(stderr, "failed to initialize allegro!\n"); 20 return -1; 21 } 22 23 display = al_create_display(width, height); 24 25 if(!display) 26 { 27 fprintf(stderr, "failed to initialize display!\n"); 28 return -1; 29 } 30 31 if(!al_install_audio()) 32 { 33 fprintf(stderr, "failed to install audio!\n"); 34 return -1; 35 } 36 37 38 if(!al_init_acodec_addon()) 39 { 40 fprintf(stderr, "failed to initialize audio codecs!\n"); 41 return -1; 42 } 43 44 if (!al_reserve_samples(1)) 45 { 46 fprintf(stderr, "failed to reserve samples!\n"); 47 return -1; 48 } 49 50 //sample = al_load_sample("Strobe.ogg"); 51 sample = al_load_sample("Legacy.flac"); 52 53 event_queue = al_create_event_queue(); 54 55 al_register_event_source(event_queue, al_get_display_event_source(display)); 56 57 al_play_sample(sample, 1, 0, 1, ALLEGRO_PLAYMODE_LOOP, NULL); 58 59 while(!done) 60 { 61 ALLEGRO_EVENT ev; 62 al_wait_for_event(event_queue, &ev); 63 64 if(ev.type == ALLEGRO_EVENT_DISPLAY_CLOSE) 65 { 66 done = true; 67 } 68 69 al_flip_display(); 70 al_clear_to_color(al_map_rgb(0, 0, 0)); 71 } 72 73 al_destroy_sample(sample); 74 al_destroy_event_queue(event_queue); 75 al_destroy_display(display); 76 77 return 0; 78}

I'm glad the inits are working properly, but I've gone over this simple code a few times and have no idea why the sample is not loading properly. Backtrace tells me that my allegro_sample *sample = 0x0 when it crashes so obv something wrong.

(*bangs head on desk repeatedly*)

Still crashes...

Edgar Reynaldo

Try this - you may need to set you current working directory.

1//ALLEGRO_PATH *al_get_standard_path(int id) 2 3ALLEGRO_PATH* path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); 4 5//const char *al_path_cstr(const ALLEGRO_PATH *path, char delim) 6 7al_change_directory(al_path_cstr(path , '\\'));// if on windows 8 9ALLEGRO_SAMPLE* sample = al_load_sample("MySound.ogg"); 10 11if (!sample) { 12 printf("Failed to load sample.\n"); 13} 14 15al_destroy_path(path); 16path = 0;


Didn't change anything. I'm compiling on linux btw. And I've been doing fine loading bitmaps and everything else, just not with audio. I'll keep trying new things.

Thomas Fjellstrom

You sure the ogg support was properly compiled in?


Everything with the audio seems to have compiled correctly, but I don't know how I would know that for sure.

Can anyone think of any other libraries I may have passed up that would cause my sample to not load correctly? Path seems fine and I have tried multiple files that all play just fine elsewhere.

I'm stumped. May be time to reinstall allegro and recompile everything.

Thomas Fjellstrom

Make sure you have the libogg-dev and libvorbis-dev and maybe libvorbisfile-dev libraries.


Thanks thomas. I installed the libogg-dev and libvorbis-dev but couldn't find libvorbisfiles-dev. Still can't load a sample. Everything allegro seems to be together correctly. I have all the acodec and audio libraries and all the audio source files like ogg.c. I'm seriously trying to run this simple program:

1#include <stdio.h> 2#include <allegro5/allegro.h> 3#include <allegro5/allegro_audio.h> 4#include <allegro5/allegro_acodec.h> 5 6int main() 7{ 8 9 int WIDTH = 500; 10 int HEIGHT = 500; 11 12 ALLEGRO_DISPLAY *display = NULL; 13 ALLEGRO_SAMPLE *sample = NULL; 14 15 al_init(); 16 17 display = al_create_display(WIDTH, HEIGHT); 18 19 al_install_audio(); 20 al_init_acodec_addon(); 21 22 al_reserve_samples(1); 23 24 al_load_sample("Strobe.ogg"); 25 26 al_play_sample(sample, 1, 0, 1, ALLEGRO_PLAYMODE_LOOP, NULL); 27 28 al_destroy_sample(sample); 29 al_destroy_display(display); 30 31 return 0; 32}

and everything compiles fine until I call al_play_sample. I debug and see that my variable sample is null. Nothing suspicious in allegro.log.

Any chance I need a different value for the sample return handle? I have it set as null as I saw in a tutorial, but it wasn't explained what its for. Doubt it matters.

Other than this audio issue I absolutely love allegro and I've had a great time with every other aspect of making this game. Let me know if anything brilliant strikes you...

Thomas Fjellstrom

Did you re-cmake and rebuild and install allegro before trying again?


Yes I did cmake make and make install again but no change. The only warning I get when I cmake allegro is for jpeg and png, which shouldn't matter, and then for dumb. I have been trying to install dumb but I get this dumb error:

src/allegro/alplay.c:22:21: fatal error: allegro.h: No such file or directory
compilation terminated.

Do I need dumb for audio or should allegro work fine without? I've searched dumbs faqs and readmes and can't find anything about this error I'm getting. Man I thought I was on a roll for my first game until I hit audio... seriously deflating.

Edgar Reynaldo

When you compile dumb, say it isn't for allegro. The allegro they're talking about is allegro 4. That's why it is looking for allegro.h and not allegro5/allegro.h.

So cmake says Pulse audio was found? And you're still getting null for al_load_sample?

If you make a debug build I can try to debug it for you. You're gonna have to drill down inside al_load_sample and see why it is returning null.


Most likely because there is no ogg support compiled in. What is the contents of your


file? (Where build is your cmake build directory.)


Looks like I just needed DUMB and the other ogg libraries installed. Seems to be working now and I can't wait to implement sound into my real project.

Thank you Edgar, Thomas, and Elias!!!

I've only started using Allegro a few weeks ago and you guys have been very helpful with this situation. I hope to share some good games with everyone in the future and I'm sure I'll need your help again in order to do that.

Thread #613780. Printed from