Bug 474745

Summary: SDL sound kinda ugly through PulseAudio when using the Pulseaudio AUDIODRIVER
Product: [Fedora] Fedora Reporter: Nate <drag>
Component: pulseaudioAssignee: Lennart Poettering <lpoetter>
Status: CLOSED NEXTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: low    
Version: 10CC: felix, hdegoede, lcarapinha, lkundrak, lpoetter, ma, martin.klapetek, mavit, nicku, zman0900
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: 1.2.13-7.fc10 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2009-03-02 17:00:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
pulseaudio -vvv output when running without "realtime-scheduling = yes"
none
pulseaudio -vvv output when running with "realtime-scheduling = yes" none

Description Nate 2008-12-05 04:46:58 UTC
Description of problem:

When playing various SDL games the sound is crackly and has other artifacts. I am using PulseAudio and this the PA support in SDL is causing this problem, I think.

I can play those games with smooth and good sound if I go:

export SDL_AUDIODRIVER="alsa"
or
export SDL_AUDIODRIVER="esd"

before running the application. The sound still goes through the PA daemon and whatnot, but now it sounds nice.

I have it set to use the Alsa output in my bashrc, but it doesn't affect applications that are launched through the menu. 


Version-Release number of selected component (if applicable):

Name       : SDL_sound
Arch       : i386
Version    : 1.0.3
Release    : 1.fc10



How reproducible:

Run x-moto or crack-attack from the menu while PA is running and you should here the poor audio output.
  
Actual results:

Sound sounds bad.

Expected results:

Sounds sound good.


Additional info:

Good job otherwise. This is the first time I didn't disable PA right away. You guys should be happy.

Comment 1 Dan Ziemba 2008-12-06 23:04:46 UTC
I can confirm this.  I am having the exact same results.  I have noticed the bad sound using the default pulse driver for sdl in both UrbanTerror and Gens (genesis emulator).  When I run these programs with SDL_AUDIODRIVER=alsa, they sound fine and still show up in PA volume control.  I don't like the esd driver because it causes a significant delay of about 1 second in the sound. 

As a workaround, I was able to set SLD_AUDIODRIVER to alsa in my ~/.bash_profile and it does work with games launched from the menu.  (Make sure you log out and back in first.)

I have experienced this problem before when I tried Ubuntu 8.04 a few months ago.  Their alsa driver for sdl cause any sdl apps to crash when playing through pulse, so I see some progress has been made there.  While trying to find a way to play some games, I found a patch for the SDL pulse driver that seemed to fix it for me on Ubuntu.  See ubuntu bug #216397.  I rebuilt libsdl1.2 with the patch from that bug and it worked great.  Perhaps this should be included in the SDL rpm?  I would try it myself, but I'm new to systems with RPM so I haven't figured out how to rebuild one yet.

Comment 2 Hans de Goede 2008-12-08 14:39:59 UTC
Nate,

I can reproduce this.

Can you please try editing (as root) /etc/pulse/daemon.conf and then uncommenting
these 2 lines:

realtime-scheduling = yes  
realtime-priority = 5  

That fixes this for me, please let me know if it also works for you, thanks.

Dan,

That patch already is part of Fedora's SDL package.

Comment 3 Nate 2008-12-08 17:20:19 UTC
Ok. I tried your suggestion out and it worked quite well. Thank you. 


Just 2 concerns:

1:
The only bad thing that happenned when I first tried it was that the sound got kinda wonky. Not scratchy or popping anymore, but sort of pausing/starting or stuttering. Killing pulseaudio and restarting it seemed to have fixed it. 

I think this may have to do with my other bug https://bugzilla.redhat.com/show_bug.cgi?id=474743 because I had two audio devices and when I closed out hte pavucontrol it seems to be what caused PA to go into a bit of a tail spin. But I don't think that has anything to do with this bug. My suggestion is to see how this config change behaves on a system with a high load vs other possible fixes.

2:
Also; Does this realtime option require the use of the pulse-rt group for the user? I don't quite understand how all the rt permissions work, but if the user needs to be a member of the pulse-rt group then I could see this being a issue since it's not the default configuration for Fedora 10, from what I can tell. 


Thanks though. This seems to have effectively solved this issue for me. I'm quite happy.

Comment 4 Lennart Poettering 2008-12-08 19:45:48 UTC
*** Bug 474450 has been marked as a duplicate of this bug. ***

Comment 5 Hans de Goede 2008-12-09 10:33:55 UTC
(In reply to comment #3)
> Ok. I tried your suggestion out and it worked quite well. Thank you. 
> 
> Also; Does this realtime option require the use of the pulse-rt group for the
> user?

No, that is the strange thing, just setting the option fixes this, even though pulseaudio will fail to acquire realtime scheduling due to permissions. I'm currently working together with the pulseaudio maintainer to track this down.

Changing component to pulseaudio and re-assigning.

Comment 6 Hans de Goede 2008-12-09 10:35:05 UTC
Created attachment 326282 [details]
pulseaudio -vvv output when running without "realtime-scheduling = yes"

Comment 7 Hans de Goede 2008-12-09 10:35:37 UTC
Created attachment 326283 [details]
pulseaudio -vvv output when running with "realtime-scheduling = yes"

Comment 8 Dan Ziemba 2008-12-12 17:51:16 UTC
(In reply to comment #2)
> Nate,
> 
> I can reproduce this.
> 
> Can you please try editing (as root) /etc/pulse/daemon.conf and then
> uncommenting
> these 2 lines:
> 
> realtime-scheduling = yes  
> realtime-priority = 5  
> 
> That fixes this for me, please let me know if it also works for you, thanks.
> 
> Dan,
> 
> That patch already is part of Fedora's SDL package.

I just gave that a try, and it made no difference for me.

Also, I've noticed that I am getting the same ugly sound I get from the pulse SDL driver through oss emulation as well.  i.e. When I run padsp <oss-only-app>, it sounds horrible.  This seems like it is probably caused by the same problem with PA.

Comment 9 Hans de Goede 2009-02-13 10:37:17 UTC
Note, a new updated SDL with a proper fix for this is on its way, when it becomes available for testing the updates-system will post a comment here with instructions how to get it.

Comment 10 Fedora Update System 2009-03-02 17:00:04 UTC
SDL-1.2.13-7.fc10 has been pushed to the Fedora 10 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 11 Luis Marques 2009-04-13 17:58:39 UTC
Hi, 
Still happens with Fedora 10 using the game World of Goo:

Installed Packages
Name       : SDL
Arch       : i386
Version    : 1.2.13
Release    : 7.fc10
Size       : 491 k

Any news about this issue? Thanks

Comment 12 Hans de Goede 2009-04-13 18:05:23 UTC
(In reply to comment #11)
> Hi, 
> Still happens with Fedora 10 using the game World of Goo:
> 
> Installed Packages
> Name       : SDL
> Arch       : i386
> Version    : 1.2.13
> Release    : 7.fc10
> Size       : 491 k
> 
> Any news about this issue? Thanks  

Maybe World of Goo forces the use of a certain SDL audio driver? Maybe it sets
a ridiculous buffer size which only works on the authors system, maybe your
system is too slow for it? Who knows with a closed binary game like this.

Try playing quake3 ("yum install quake3-demo") for example, or other SDL programs
if only World of Goo suffers from this, file a bug with them.

Also what does "printenv SDL_AUDIODRIVER" say? The output of that command should be empty.

Comment 13 Hans de Goede 2009-04-13 18:34:15 UTC
(In reply to comment #11)
> Hi, 
> Still happens with Fedora 10 using the game World of Goo:
> 
> Installed Packages
> Name       : SDL
> Arch       : i386
> Version    : 1.2.13
> Release    : 7.fc10
> Size       : 491 k
> 
> Any news about this issue? Thanks  

Just downloaded it myself, as suspected its a bug of the blob. Edit the
WorldOfGoo bash script and remove the:
export LD_LIBRARY_PATH=libs

From the script, then you will actually be using Fedora's version of SDL,
hopefully that helps.

Comment 14 Luis Marques 2009-04-13 18:42:44 UTC
Hi, 
Still happens with Fedora 10 using the game World of Goo:

Installed Packages
Name       : SDL
Arch       : i386
Version    : 1.2.13
Release    : 7.fc10
Size       : 491 k

Any news about this issue? Thanks

Comment 15 Luis Marques 2009-04-13 18:46:44 UTC
Opps, sorry about repetitive comment.

We after installed SDL_mixer.i386 0:1.2.8-9.fc10 the game run pretty well and there is no glitches with pulseaudio.

Now my monitor shows (input not supported) floating around the screen in a gray box but the game works fine.
But this isn't a pulseaudio+SDL problem.

Thanks