PulseAudio sound workaround on Linux

Technical support for the Linux and Mac platforms for Shadowgrounds and Shadowgrounds Survivor.
Yfrwlf
Posts: 11
Joined: Sat Apr 16, 2011 4:03 am

PulseAudio sound workaround on Linux

Postby Yfrwlf » Sat Apr 16, 2011 4:16 am

To get sound working on Linux machines with PulseAudio, I found putting "padsp" in front of the launcher command works nicely. Running Ubuntu 11.04.

Example:

Code: Select all

padsp /home/yfrwlf/Games/shadowgrounds/shadowgrounds-launcher


I thought I'd share that, plus ask why this bug exists and workaround is needed? Is there an unreliable ABI being used for sound for the Shadowgrounds games? Is it PulseAudio's fault? Ubuntu's fault? What is going on? It's just sad that such a workaround is needed for a still fairly newish game. Anyone know?

Thanks! ^^


P.S. Just wanted to add that with Trine, there are no sound issues. Perhaps whatever Trine is using for its sound is much better! Thanks for that! Too bad the Shadowgrounds games can't use the same!

User avatar
fb_joel
Site Admin
Posts: 2482
Joined: Fri Feb 18, 2005 2:14 pm
Location: Finland

Re: PulseAudio sound workaround on Linux

Postby fb_joel » Sat Apr 16, 2011 11:21 pm

The Shadowgrounds games were actually done a couple of years ago so they probably use a little older methods for sounds, whereas Trine is a fresh port. I'm just guessing that might have something to do with it, I don't have deeper knowledge into this.

Nevertheless, glad to hear it works with that, and thanks for posting this. :)
// Joel, Frozenbyte team

Xpander
Posts: 34
Joined: Fri Apr 15, 2011 5:40 am
Location: Estonia

Re: PulseAudio sound workaround on Linux

Postby Xpander » Mon Apr 18, 2011 1:29 pm

using 11.04 with pulseaudio also and never had soundissues with any of the native linux games so far.
ofc i have upgraded my system since 7.04, so there might be some hacks that i used when pulseaudio was young on ubuntu.

only hack i found from my system is /etc/asound.conf
which has following:

# Select PulseAudio as the default sound device
pcm.!default {
type pulse
}


maybe that will help in the sound issues cases?
cuz i remember putting it into there when i had trouble with flashplayer sounds.
i might be wrong ofc. Dont think i have other hacks atm and games that i play never had audio issues including frozenbyte bundle games.
Linux Mint 13 alpha 64bit
* AMD Phenom II x4 955 BE (3,2 ghz)
* 8GB ddr3 1600mhz
* Asus GTX 560Ti DirectCU

alt_turo
Posts: 195
Joined: Mon Dec 13, 2010 11:06 am

Re: PulseAudio sound workaround on Linux

Postby alt_turo » Tue Apr 19, 2011 3:24 pm

Yfrwlf wrote:I thought I'd share that, plus ask why this bug exists and workaround is needed? Is there an unreliable ABI being used for sound for the Shadowgrounds games? Is it PulseAudio's fault? Ubuntu's fault? What is going on? It's just sad that such a workaround is needed for a still fairly newish game.


The problem goes something like this:

When PulseAudio is enabled regular ALSA is not accessible. libasound detects this and tries to work around it by loading a pulseaudio module. If the module is found everything is fine. First problem is that by default alsa only looks for this module in /usr/lib. If it's not found or it's the wrong version sound doesn't work. I added a hack to the version shipped with the game to also look under our shipped libraries but apparently this is not enough in all cases. The game was compiled on Debian Lenny and the libraries came from there. Lenny is rather old and so has old libraries. I'm not sure if PulseAudio has a stable API/ABI so this might be another problem. Then there's the problem that some distributions like to put the modules under /usr/lib64 instead of /usr/lib.

All of these problems can be worked around by removing the shipped libasound and using the system-provided one. For the next update this library has been left out so this should happen by default. I assume libasound is sufficiently common library that it's included by all distros.
Turo Lamminen
Alternative Games

Yfrwlf
Posts: 11
Joined: Sat Apr 16, 2011 4:03 am

Re: PulseAudio sound workaround on Linux

Postby Yfrwlf » Sat Apr 23, 2011 10:09 pm

alt_turo wrote:
Yfrwlf wrote:I thought I'd share that, plus ask why this bug exists and workaround is needed? Is there an unreliable ABI being used for sound for the Shadowgrounds games? Is it PulseAudio's fault? Ubuntu's fault? What is going on? It's just sad that such a workaround is needed for a still fairly newish game.


The problem goes something like this:

When PulseAudio is enabled regular ALSA is not accessible. libasound detects this and tries to work around it by loading a pulseaudio module. If the module is found everything is fine. First problem is that by default alsa only looks for this module in /usr/lib. If it's not found or it's the wrong version sound doesn't work. I added a hack to the version shipped with the game to also look under our shipped libraries but apparently this is not enough in all cases. The game was compiled on Debian Lenny and the libraries came from there. Lenny is rather old and so has old libraries. I'm not sure if PulseAudio has a stable API/ABI so this might be another problem. Then there's the problem that some distributions like to put the modules under /usr/lib64 instead of /usr/lib.

All of these problems can be worked around by removing the shipped libasound and using the system-provided one. For the next update this library has been left out so this should happen by default. I assume libasound is sufficiently common library that it's included by all distros.


Geez, it's embarrassing that static paths are still being relied upon for things instead of having a set of standard environmental variables or some kind of way that programs can use to always find out where a particular library is. Or better yet, just making a basic system call for something and let the system deal with it as the system should know where it is. :P

Correct me if I'm wrong but it just all seems like a problem with a lack of standards and communication to me. If I were a developer, I would demand all interfaces used standardised and stable ABI/APIs, and that there was a solid system for resolving dependencies in place. Shipping everything you can bundled together is one quick fix for the latter issue, but of course using a universal package management system like Zero Install or something could potentially cut down on bloat.

No matter the fix I use, I have a problem where playing for a few missions ends up cutting out some, and eventually all of the sound, like there's some kind of buffer that is filling up and running out of space eventually. :( Restarting SG fixes it temporarily at least!

TTIO
Posts: 7
Joined: Fri Apr 22, 2011 7:09 pm

Re: PulseAudio sound workaround on Linux

Postby TTIO » Sat Apr 23, 2011 10:16 pm

Offtopic:

Hmm, interesting. ALSA is apparently interfering with pulse on my computer, I can't currently get any sound on Linux >_<

Am I right in thinking, that if I set up my system to only use pulse, ALSA will be disabled? That'd fix my problem, according to the guy on LinuxForums.

alt_turo
Posts: 195
Joined: Mon Dec 13, 2010 11:06 am

Re: PulseAudio sound workaround on Linux

Postby alt_turo » Tue Apr 26, 2011 1:33 pm

Actually it's the other way around, PulseAudio interferes with ALSA. Some common workarounds:

1. Use padsp: padsp ./survivor-bin

2. Disable pulseaudio entirely

3. Remove lib32/libasound.so.2. Your system must have a compatible libasound.so.2 installed

Yfrwlf wrote:No matter the fix I use, I have a problem where playing for a few missions ends up cutting out some, and eventually all of the sound, like there's some kind of buffer that is filling up and running out of space eventually. :( Restarting SG fixes it temporarily at least!

Yeah that code is horrible and buggy. Mac doesn't have FMOD so I ported OpenAL code from Trine to Shadowgrounds. Worked fine except the music was sometimes choppy because sound update was not being called often enough. On Trine this had been fixed properly but it required things like background loading of files which was too invasive change for Shadowgrounds.

So I fixed it by moving sound decoding and playing to a separate thread. Most computers are at least dual core, OpenAL documentation says this is OK and it works fine on Linux. Problem solved, right?

Wrong. Mac threw a fit. No matter what we did the Mac version would always crash very shortly. And I couldn't find the bug on Linux no matter what. So in the end I moved the entire sound system to a separate thread. This at least made Mac stop crashing but unfortunately there's still a bug somewhere. For some reason OpenAL sound sources are not properly cleaned up which eventually makes sound stop working. At this point we'd spent several weeks on this, deadline was looming and frustration was high. So our options were 1) accept choppy music playback, 2) accept crashing on Mac or 3) accept occasional need to restart the game when the sounds bug out. Number three was chosen as the least bad option.

tl;dr: Blame Macs shitty OpenAL implementation for any sound bugs.

When FB releases the Linux source for SG I'll go back and get the working OpenAL code from our internal Subversion and post that. That'll allow you to get better sound playback if you don't care about Macs.
Turo Lamminen
Alternative Games

ninex
Posts: 2
Joined: Sat Apr 30, 2011 8:16 pm
Location: Poland
Contact:

Re: PulseAudio sound workaround on Linux

Postby ninex » Sat Apr 30, 2011 8:37 pm

adding this to ~/.asoundrc also helps ;)

Code: Select all

# Select PulseAudio as the default sound device
pcm.!default {
    type pulse
}

Yfrwlf
Posts: 11
Joined: Sat Apr 16, 2011 4:03 am

Re: PulseAudio sound workaround on Linux

Postby Yfrwlf » Mon May 09, 2011 2:54 am

For some reason padsp is no longer needed in Ubuntu 10.10, and a new install of the Shadowgrounds games from the latest update 3 seems to have fixed the problem.

sleeper
Posts: 1
Joined: Tue May 10, 2011 4:59 am

Re: PulseAudio sound workaround on Linux

Postby sleeper » Tue May 10, 2011 5:05 am

I had a similar problem while running Fedora 14 x64 after downloading survivorUpdate1.run even after trying the above workarounds.

I was getting an error of "ALSA lib dlmisc.c:236:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_pulse.so"

The problem was that the 32bit version of alsa-plugins-pulseaudio wasn't installed.

After running:

[[email protected] ~]# yum install alsa-plugins-pulseaudio.i686

sounds started working as expected.

Yfrwlf
Posts: 11
Joined: Sat Apr 16, 2011 4:03 am

Re: PulseAudio sound workaround on Linux

Postby Yfrwlf » Tue May 10, 2011 3:11 pm

sleeper wrote:I had a similar problem while running Fedora 14 x64 after downloading survivorUpdate1.run even after trying the above workarounds.

I was getting an error of "ALSA lib dlmisc.c:236:(snd1_dlobj_cache_get) Cannot open shared library /usr/lib/alsa-lib/libasound_module_pcm_pulse.so"

The problem was that the 32bit version of alsa-plugins-pulseaudio wasn't installed.

After running:

[[email protected] ~]# yum install alsa-plugins-pulseaudio.i686

sounds started working as expected.


After playing for a while (maybe an hour or more) do you get the sound stopping on you too? I will get the sounds slowly failing to work until it's completely silent.

None of this is a problem in Trine!


Return to “Technical support for Linux & Mac”

Who is online

Users browsing this forum: No registered users and 0 guests