The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.


SDL Forum Index
SDL
Simple Directmedia Layer Forums
SDL_mixer sound lag in 64-bit Linux (but not in 32-bit)
Gerry JJ
Guest

Hello. I recently got a new PC with an amd64 processor, and now I'm having
problems with lag in SDL_mixer, with a constant sound delay of about a
second
whenever sound plays (using Linux). The sound card is some motherboard-
integrated thing using ALSA's intel8x0 driver. Other programs using ALSA
for
sound output doesn't have this delay, so I don't think it's a problem with
the
sound card driver. Also, 32-bit SDL programs doesn't have this problem,
the
lag *only* shows up in 64-bit SDL programs.

This is all using SDL's ALSA driver. I tried setting the audio driver to
OSS (using SDL_AUDIODRIVER=oss), but this resulted in no sound at all
(despite
having ALSA's OSS compatibility enabled in the kernel).

Does anyone have any idea what might be causing this, and if there's
something
I could do to fix it ? (First thing that springs to mind is that the SDL
audio
code might not be 64-bit clean on x86, but if that was true it seems
strange
that noone would have reported a problem before ? I couldn't find anything
about it, at least).

Thanks,
- Gerry JJ
SDL_mixer sound lag in 64-bit Linux (but not in 32-bit)
David Olofson
Guest

On Saturday 21 January 2006 22:14, Gerry JJ wrote:
[...]
Quote:
Does anyone have any idea what might be causing this, and if there's
something I could do to fix it ?

Well, if you have some spare sound card around... Then again, if
"everything else" works, that probably won't make a difference.

However, I think SDL uses memory mapped audio whenever it can. Have
you tried running Q3A, RTCW, Doom 3 or something else that does that
too? Q3A and RTCW support only OSS, but Doom 3 supports ALSA
natively. (Which means I only get sound in Doom 3 ATM. Can't be arsed
to install the ALSA emulation, and the user space OSS emulation thing
that Gentoo provides doesn't work properly with Q3A and RTCW.)


Quote:
(First thing that springs to mind
is that the SDL audio code might not be 64-bit clean on x86, but if
that was true it seems strange that noone would have reported a
problem before ? I couldn't find anything about it, at least).

Sound in 64 bit SDL Works Here(TM)... (SB Audigy, Gentoo/AMD64, ALSA,
no OSS emulation.)


//David Olofson - Programmer, Composer, Open Source Advocate

.------- http://olofson.net - Games, SDL examples -------.
| http://zeespace.net - 2.5D rendering engine |
| http://audiality.org - Music/audio engine |
| http://eel.olofson.net - Real time scripting |
'-- http://www.reologica.se - Rheology instrumentation --'
SDL_mixer sound lag in 64-bit Linux (but not in 32-bit)
Gerry JJ
Guest

On Sun, 22 Jan 2006 10:33:15 +0100, David Olofson <david at olofson.net>
wrote:
Quote:
On Saturday 21 January 2006 22:14, Gerry JJ wrote:
[...]
Quote:
Does anyone have any idea what might be causing this, and if there's
something I could do to fix it ?

Well, if you have some spare sound card around... Then again, if
"everything else" works, that probably won't make a difference.

I do have a spare sound card, but it's a little buggy, so I'd rather not
use it. I've also got limited space for PCI cards =(.

Quote:
However, I think SDL uses memory mapped audio whenever it can. Have
you tried running Q3A, RTCW, Doom 3 or something else that does that
too? Q3A and RTCW support only OSS, but Doom 3 supports ALSA
natively. (Which means I only get sound in Doom 3 ATM. Can't be arsed
to install the ALSA emulation, and the user space OSS emulation thing
that Gentoo provides doesn't work properly with Q3A and RTCW.)

I've tried Doom 3, which works fine, but then again that's only available
in 32-bit, and as I mentioned before 32-bit SDL also works fine. Are there
any 64-bit games/apps that does this that I could try, or a way to turn off
mmapped audio in SDL to test if that works ?

Btw, I also tried the 64-bit exe of your DT-42 (which I love, btw), which
also had this problem, so if there's an SDL-related problem, it's in SDL,
not in SDL_mixer.

Quote:
Quote:
(First thing that springs to mind
is that the SDL audio code might not be 64-bit clean on x86, but if
that was true it seems strange that noone would have reported a
problem before ? I couldn't find anything about it, at least).

Sound in 64 bit SDL Works Here(TM)... (SB Audigy, Gentoo/AMD64, ALSA,
no OSS emulation.)

So I'm pretty much out of luck, then ? I'm guessing there isn't any audio-
driver-specific code in SDL ? Any idea why 32-bit SDL would work but
64-bit
SDL doesn't ?

- Gerry
SDL_mixer sound lag in 64-bit Linux (but not in 32-bit)
Ryan C. Gordon
Guest

Quote:
Well, if you have some spare sound card around... Then again, if
"everything else" works, that probably won't make a difference.

fwiw, my Audigy card was completely hosed (output was static) with the
ALSA drivers in 2.6.12 in 64-bit mode, while the OSS emu10k1 driver was
fine. I built the latest stable ALSA drivers from alsa-project.org, and
the problems totally vanished.

It's worth noting that even though ALSA is a part of the kernel now, it
seems that they still do their development independently, and
occasionally a kernel maintainer syncs up with their releases, so it
might be worth trying that manual upgrade.

Also, if you weren't previously using ALSA and now you are, the default
values might be up way too high, and can be tweaked in ~/.asoundrc:


http://icculus.org/cgi-bin/ezmlm/ezmlm-cgi?50:mss:120:200509:apbjmjknnpdaibahndfg

--ryan.
SDL_mixer sound lag in 64-bit Linux (but not in 32-bit)
Gerry JJ
Guest

On Sun, 22 Jan 2006 16:10:35 +0100, Ryan C. Gordon <icculus at icculus.org>
wrote:
Quote:
Also, if you weren't previously using ALSA and now you are, the default
values might be up way too high, and can be tweaked in ~/.asoundrc:

Thanks. This box has been using ALSA exclusively since the install, but
I guess the default values were way too high anyway. Simply adding

period_size 1024
buffer_size 4096

to ~/.asoundrc or /etc/asound.conf didn't work, but I did some searching
and found a working .asoundrc, here:

http://forums.gentoo.org/viewtopic-t-409806.html#2938602

Using this reduces the lag *significantly*. A buffer size of 8192 was a
bit high, though, so I tried 4096 and then 2048, which is perfect for me,
without any noticable lag or skipping. Thanks to everyone for your help!

(Btw, because I'm curious, I'd still like to know why this was only a
problem with SDL in 64-bit mode, if anyone has any thoughts about that)

- Gerry