Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » al_load_sample mysteriously always returning NULL

Credits go to Edgar Reynaldo and Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
al_load_sample mysteriously always returning NULL
roger levy
Member #2,513
July 2002

I've verified that al_install_audio and al_init_acodec_addon are being called and returning 1. The files I'm trying to load definitely exist and I definitely have the path correct. Is there a way to get more detailed information about why al_load_sample is failing? Any ideas on things to try?

Thomas Fjellstrom
Member #476
June 2000
avatar

First try using al_filename_exists to see if the file actually is where your program thinks it is.

Then try using the debug version of allegro and checking allegro.log to see if it says anything about loading the file.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

roger levy
Member #2,513
July 2002

I haven't compiled any debug binaries :(

I remember the process of building Allegro 5.1.9 being a day-long project so I'm not looking forward to the prospect of trying to build the debug dll's...

Edgar Reynaldo
Member #8,592
May 2007
avatar

I distribute MinGW 4.8.1 and Allegro 5.1.9 binaries for MinGW 4.8.1 too if you're interested.

See here

http://sourceforge.net/projects/unofficialmingw/files/latest/download?source=files

and here

http://sourceforge.net/projects/unofficialallegro5distribution/files/latest/download?source=files

All the dependencies are provided with allegro. You can try the examples included with Allegro 5.1.9 - they are statically linked debug executables. And then you could try ex_sample and see if it works for you.

Thomas Fjellstrom
Member #476
June 2000
avatar

I remember the process of building Allegro 5.1.9 being a day-long project so I'm not looking forward to the prospect of trying to build the debug dll's...

If you've already done it, and still have the build dir, all you have to do is change the build type in cmake, run make, and install.

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

roger levy
Member #2,513
July 2002

I don't remember anything about the build process - what programs I used, what buttons to click, what commands to type - nothing. Besides that, I recently wiped my laptop, so nothing that was installed to accomplish the first build is currently installed.

The allegro.log is attached, generated with Edgar's debug DLL. al_load_sample doesn't seem to be adding anything to the log file.

Thomas Fjellstrom
Member #476
June 2000
avatar

Then the file just isn't being found, or the file is not the right format. Have you tried using al_filename_exists to see if the path is right?

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

roger levy
Member #2,513
July 2002

I have tried different files and formats. I have also tried al_filename_exists to verify the paths, and got 1 back.

Edit: Well, I wrote some test code to isolate all initialization to just an Allegro window and the audio subsystems and was able to load and play a sound. What this means, who knows yet... boy is this fun!

Edit 2: I seem to be able to only load 16-bit WAV files. 24-bit WAV doesn't work, but neither does OGG nor MP3. This is really puzzling because I used to be able to - seeing as I released an entire game that used tons of ogg files.

Edit 3: I found the problem. It seems that my Windows installation doesn't have the dependencies acodec uses in the path, and lazy-loading of the libvorbis DLL is being utilized when an ogg sample is loaded for the first time. My latest log file shows that libvorbis isn't being found.

Edgar Reynaldo
Member #8,592
May 2007
avatar

And then you could try ex_sample and see if it works for you.

Sorry, that is the name of the A4 example. In A5 it is ex_audio_simple or ex_acodec and such. You could try loading your audio files through ex_audio_simple and see if my static link examples are able to load them. If so, then you might not have built support in for them when you ran cmake and built your other version because it didn't find the right dependencies or something. The dlls are provided for most dependencies in my A519 package also.

roger levy
Member #2,513
July 2002

Everything is fine now, I just had to add my library folder to the path and add instructions to the readme that others need to do the same. Thanks for the help guys

Go to: