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.
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?
5.0.10 https://www.allegro.cc/forums/thread/613387
5.1.8 https://www.allegro.cc/forums/thread/613773
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.
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 :
Backtrace after program crashes:
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
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:
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.
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:
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:
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...
Try this - you may need to set you current working directory.
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.
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.
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:
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...
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.
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
/build/include/allegro5/internal/aintern_acodec_cfg.h
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.