Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » More Allegro sound problems with Linux

Credits go to Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
More Allegro sound problems with Linux
agent_smith
Member #10,673
February 2009

I'm running Ubuntu 9.04 and "had" allegro + codeblocks running well. I bought a new hard drive and decided to reinstall Ubuntu on the new hard drive. I install Ubuntu 9.04 the sound works and after installing codeblocks and allegro I compiled my game and its returning a -1 during runtime with this line of code:

if (install_sound(DIGI_AUTODETECT, MIDI_NONE, ""))

{

allegro_message("initialize.c -> Error initialising sound system");

return 1;

}

The game will run without sound. This is the exact same code I had before. One of the interesting things is if I take the BINARY of my game from the other Ubuntu 9.04 where everything was working and run it on the new installation the sound works fine. The code is the same and the gcc version is the same, the codeblocks is the same, the OS is the same.

I also got a new laptop with the same version of the other two installations and its having the exact same problem with the "install_sound" line as with the install on the new hard drive. Anyone have any ideas?

Thank you

UPDATE:

Although Pulse is installed by default I uninstalled everything that had "Pulse" in it and now the sound works. Unfortunately I uninstalled about 20 packages so I don't know which one affected the install_sound error at runtime however I'll uninstall the packages one at a time on my laptop and then post my results here.

Thomas Fjellstrom
Member #476
June 2000
avatar

Its probably pulse taking over. Technically allegro's ALSA and OSS drivers SHOULD beable to work with Pulse Audio, but I don't think anyone has spent time testing it.

--
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

agent_smith
Member #10,673
February 2009

I figured when I took out the Pulse packages but what I don't understand is why the binary that was compiled on the same system works. Since this is from the same code and the problem happens at runtime, why doesn't the other binary report the same error?

I'm going to start removing the Pulse packages from my desktop to see which one is causing the problem. Before I reinstalled Linux I had the same packages installed so I thought it might be a setting somewhere in the prefs that got change when other packages were installed but I'm unable to confirm this.

Thomas Fjellstrom
Member #476
June 2000
avatar

Pulse Audio takes over the main "alsa" devices, and doesn't completely support the ALSA api, so any code that uses bits that Pulse doesn't support ends up broken. I think it was a horrible decision made by the Gnome and distros to start using it en-masse before it was completely ready. But like the Network Manager folks, they seem to think not supporting many configurations is a feature not a bug.

--
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

agent_smith
Member #10,673
February 2009

Yea but I'm still not understanding how the binary which is from the same code and the code is being compiled by the same version of gcc and is running on the same OS and kernel version (same computer different hard drive) yet when recompiled with this installation it has no sound during runtime the already compiled from the different hard drive works fine. Shouldn't they both work or both not work? What is in the one binary that the other one doesnt have is my question. They were compiled on different hard drives with the exact same hardware & software.

Anyways if anyone else runs into this problem the package that needs to be removed is:

pulseaudio

You only need to remove this package. All of its dependencies can stay and loading in various other pulse packages (vlc, xmms plugin for example) doesn't have any affect on this sound issue.

Thomas Fjellstrom
Member #476
June 2000
avatar

One of the versions might be using OSS, and the other ALSA.

--
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

agent_smith
Member #10,673
February 2009

I think you're right; although the code in both the source code uses:

-> install_sound(DIGI_AUTODETECT, MIDI_NONE, "")

If I change the DIGI_AUTODETECT to DIGI_OSS it works with sound (yay thank you Thomas for the suggestion). With DIGI_AUTODETECT I printed out allegro_error:

"Last Allegro error `ALSA: snd_pcm_hw_params_set_format(pcm_handle, hwparams, format) : Invalid argument'

I looked it up and I guess some people already have been attacking this issue:

After some (a lot of) poking, I've discovered that Allegro uses SND_PCM_FORMAT_U16_BE and SND_PCM_FORMAT_U16_LE to set the format, and these are NOT DEFINED in PA's alsa-util.c. alsa-util.c only defines translations for SND_PCM_FORMAT_S16_LE and SND_PCM_FORMAT_S16_BE, but not the unsigned equivalents, so Allegro's sound format gets assigned PA_SAMPLE_INVALID, which of course would make the "Invalid argument" message make sense.

This is from: http://www.pulseaudio.org/ticket/133

Reading on I discovered that this bug has been fixed in Allegro 4.3.10
http://alleg.svn.sourceforge.net/viewvc/alleg?view=rev&revision=9936

So the only way I can think why the binary from the other system works and this one doesn't and they both used the same code is if I compiled a version of allegro that is greater than 4.3.10 instead of using the repositories to install allegro (4.2 is installed). I don't remember doing this (I thought I went through the repositories) but this is the only valid reason I could come up with that explains what is happening. Brain fail :(

Thank you again Thomas for responding and helping me!!

Go to: