FS#3294 - 100% CPU usage and game crash on exit due to SDL sound frequency

Attached to Project: OpenTTD
Opened by Hugo van der Wijst (Jafinto) - Monday, 02 November 2009, 22:42 GMT
Last edited by Remko Bijker (Rubidium) - Tuesday, 03 November 2009, 13:33 GMT
Type Bug
Category Core
Status Closed
Assigned To No-one
Operating System Linux
Severity Medium
Priority Normal
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No


When I run any build > 17140 the game uses 100% of my CPU, while it otherwise hovers around the 12%. When I try to close the game, it hangs. Sounds do not play normally.

I can fix this by setting the SDL frequency to 11025 (I'm using the standard sounds).

My system:
Ubuntu 9.10 Karmic Koala
AMD Phenom II X4 810 Processor
AMD Radeon HD 3300 (integrated)
Creative X-Fi Platinum
This task depends upon

Closed by  Remko Bijker (Rubidium)
Tuesday, 03 November 2009, 13:33 GMT
Reason for closing:  Bug in external library
Additional comments about closing:  libSDL->SDL-ALSA backend->PulseAudio virtual ALSA device->PulseAudio causes the problem. Switch to either the SDL-PulseAudio backend or remove PulseAudio.
Comment by Zdeněk Sojka (SmatZ) - Monday, 02 November 2009, 23:26 GMT
From known-bugs.txt:

Extreme CPU usage when using SDL and PulseAudio
OpenTTD can be extremely slow/use a lot of CPU when the sound is
played via SDL and then through PulseAudio's ALSA wrapper. This setup
seems to be the default configuration for Ubuntu 9.04 and later. This
issue can be solved by installing the 'libsdl1.2debian-pulseaudio'
package from Ubuntu's Universe repository.

(yes, I know it's not fair as this was added to known-bugs.txt today)

Does that help?
Comment by Hugo van der Wijst (Jafinto) - Tuesday, 03 November 2009, 10:22 GMT
It does fix the high CPU load and the crash on exit, but the sound quality is noticeably worse.

Anyway, thanks for workaround. I think I'll just keep the frequency on 11025 for now, until the new sound set will be ready.