The Ur-Quan Masters Home Page Welcome, Guest. Please login or register.
Did you miss your activation email?
November 11, 2024, 05:35:04 pm
Home Help Search Login Register
News: Celebrating 30 years of Star Control 2 - The Ur-Quan Masters

+  The Ur-Quan Masters Discussion Forum
|-+  The Ur-Quan Masters Re-Release
| |-+  Technical Issues (Moderator: Death 999)
| | |-+  Sound delays with mixsdl
« previous next »
Pages: [1] Print
Author Topic: Sound delays with mixsdl  (Read 5365 times)
TigTigger
Zebranky food
*
Offline Offline

Posts: 41



View Profile
Sound delays with mixsdl
« on: June 05, 2006, 10:36:23 pm »

Hey all,

I am not sure if this is a bug or not, but..

I've normally just run uqm on my Windows machine, but I figured I'd take a stab and getting it running on my Linux machine.  It's uqm 0.5 on Fedora Core 4, installed SDL devel packages via yum, but compiled from source since the repos still only have uqm 0.4.

The game works well, except that all of the sound effects are delayed by about 300ms, using mixsdl and ALSA.  It's quite irritating.  Conversely, speech works just fine- there are no delays at all when skipping back and forth through conversations, for example.

Now, if I switch to OpenAL sound, there is zero delay with the sound effects- although instead the sound is scratchy.  Guess it is indeed still "experimental".

All other sound on the machine works fine, too.

The only possible clue is these (possibly normal) messages:
Code:
_GetSoundBankData(): loading lbm/menusnd01.wav
SoundDecoder_DecodeAll(): WARNING, called with a small buffer (4096)
_GetSoundBankData(): loading lbm/menusnd02.wav
SoundDecoder_DecodeAll(): WARNING, called with a small buffer (4096)
_GetSoundBankData(): loading lbm/menusnd03.wav
SoundDecoder_DecodeAll(): WARNING, called with a small buffer (4096)
_GetSoundBankData(): loading lbm/menusnd04.wav
SoundDecoder_DecodeAll(): WARNING, called with a small buffer (4096)
I've read a couple of threads already on similar issues, but it looks like they were due to arts/esl.  I have neither running- and the issue is only present with mixsdl. not with openal.

Should I post a bug report, or is there something I might be doing wrong?  Anything else that I could provide?
Logged
meep-eep
Forum Admin
Enlightened
*****
Offline Offline

Posts: 2847



View Profile
Re: Sound delays with mixsdl
« Reply #1 on: June 06, 2006, 08:02:06 am »

A few remarks.
  • Avoid OpenAL. It's unusable more often than it is usable. This is because of the OpenAL lib itself, not our support of it.
  • The buffer warnings are innocent. In fact, small buffers are better for low delay. Small buffers could cause hickups, but long delays would be the result if buffers are too large. I don't know why we still generate this warning.
  • Arts causes long delays. It may also cause problems if it's running even when other programs use ALSA or OSS. Doing 'artsshell suspend' before running such programs if you have problems.
  • You can use the SDL_AUDIODRIVER environment variable to tell SDL (used by UQM) which audio driver to use. See here.

Logged

“When Juffo-Wup is complete
when at last there is no Void, no Non
when the Creators return
then we can finally rest.”
TigTigger
Zebranky food
*
Offline Offline

Posts: 41



View Profile
Re: Sound delays with mixsdl
« Reply #2 on: June 07, 2006, 06:03:39 am »

Hi,

Thanks for your message,

A few remarks.
  • Avoid OpenAL. It's unusable more often than it is usable. This is because of the OpenAL lib itself, not our support of it.
S'fine, but, I just wanted to show that the sound delays don't appear in that mode, which I thought would be helpful for troubleshooting.

  • Arts causes long delays. It may also cause problems if it's running even when other programs use ALSA or OSS. Doing 'artsshell suspend' before running such programs if you have problems.
I've already stated that arts is not running...

  • You can use the SDL_AUDIODRIVER environment variable to tell SDL (used by UQM) which audio driver to use. See
here.
See above.  ALSA is my only choice, unless I actually start one of those gruesome daemons up.

Anything else I should be looking at?
Logged
fossil
Core Team
Frungy champion
*****
Offline Offline

Gender: Male
Posts: 94



View Profile
Re: Sound delays with mixsdl
« Reply #3 on: June 07, 2006, 10:28:58 am »

It could be any of a number of things going wrong. What is strange here is that you say that sound effects have latency and speech does not, which is not really possible with mixsdl (unless I am seriously missing something here). Could it merely be a perceptional issue?

I had a similar problem on RedHat 8/9 with OSS. To fix it I played with SDL_PATH_DSP envvar to override the default playback device. It can take values /dev/sound/dsp, /dev/dsp and /dev/audio (from best to worst). I do not really know if ALSA has similar things of if you can use OSS.

Because of the architecture of certain SDL audio drivers, sound latency can sometimes be substantial and quite annoying indeed. Please look at the console output (the very beginning) or the log file (can be created with -l log-file-name) for the lines that look like so:

Opening SDL audio device.
    using dsound at 44100 Hz 16 bit stereo, 4096 samples audio buffer

and post them here. This may tell us exactly what the problem is.
Logged
TigTigger
Zebranky food
*
Offline Offline

Posts: 41



View Profile
Re: Sound delays with mixsdl
« Reply #4 on: June 07, 2006, 02:24:38 pm »

Thanks for your reply,

It could be any of a number of things going wrong. What is strange here is that you say that sound effects have latency and speech does not, which is not really possible with mixsdl (unless I am seriously missing something here). Could it merely be a perceptional issue?

You understood correctly.  There are definitely, 100% sure, delays with the sound effects, but not the voices.  Using the left and arrow keys with the voices show that the next (or previous) speech immediately starts playing.  And, there is also definitely no sound latency at all using OpenAL.  The former are .wav files and the latter are .ogg files - not sure if that might matter.

I had a similar problem on RedHat 8/9 with OSS. To fix it I played with SDL_PATH_DSP envvar to override the default playback device. It can take values /dev/sound/dsp, /dev/dsp and /dev/audio (from best to worst). I do not really know if ALSA has similar things of if you can use OSS.

Thanks for the suggestion, but, this doesn't appear to help at all- unless I need to set something else to have it write right to the audio device?

Because of the architecture of certain SDL audio drivers, sound latency can sometimes be substantial and quite annoying indeed. Please look at the console output (the very beginning) or the log file (can be created with -l log-file-name) for the lines that look like so:

Opening SDL audio device.
    using dsound at 44100 Hz 16 bit stereo, 4096 samples audio buffer

and post them here. This may tell us exactly what the problem is.

Sure thing.  Here's the relevant section.

Code:
0 joysticks were found.
Initializing SDL audio subsystem.
SDL audio subsystem initialized.
Opening SDL audio device.
    using alsa at 44100 Hz 16 bit stereo, 940 samples audio buffer
Initializing mixer.
Mixer initialized.
Initializing sound decoders.
Sound decoders initialized.
        'starcon.lst' -- 12386 bytes
        'lbm/scclrtab.ct' -- 104466 bytes
We've loaded the Kernel

Oh, I also tried changing the sound quality, to no help.
Logged
fossil
Core Team
Frungy champion
*****
Offline Offline

Gender: Male
Posts: 94



View Profile
Re: Sound delays with mixsdl
« Reply #5 on: June 08, 2006, 02:17:07 am »

I am curious what your hardware is like. The 940-samples audio buffer at 44KHz is actually way small (~21 milliseconds of audio), considering that UQM mixsdl requests 4096-samples buffer. If your system is not too fast, the CPU might not be keeping up and spending a lot of time in the mixer function. With such a small audio buffer, the OS is task-switching more than it should, and if the OS is trying its hardest to schedule the mixer task on time, the mixer will keep preempting other tasks and will keep the locks (mutexes). The sound fx queueing involves many locking operations, and if the queueing has to wait on these locks a lot, the sounds will be delayed.
You can tell if that's what is going on by playing Super Melee. If the frame rate stutters a lot, your CPU is not being able to keep up. This is all only an educated guess, however. If it's not the CPU, the only other thing I can suggest is try a different sound system (OSS for example) and/or hardware.
Logged
TigTigger
Zebranky food
*
Offline Offline

Posts: 41



View Profile
Re: Sound delays with mixsdl
« Reply #6 on: June 09, 2006, 02:57:11 am »

The machine is a AMD 2600+, 768MB of RAM.  The sound card is the onboard card:

Code:
$ cat /proc/asound/cards
 0 [SI7012         ]: ICH - SiS SI7012
                      SiS SI7012 with CMI9739 at 0xdc00, irq 17

Super-Melee plays nice and fast, as one would expect, except with the same delayed sound effects (unless I use OpenAL, again).

I've also tried a number of other games and apps, including even installing Unreal Tournament 2004 (the machine has an old FX5200 card).  I can not get any other program to reproduce this behavior.

So if this buffer size is smaller than what was requested, what could this mean?
Logged
Novus
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1938


Fot or not?


View Profile
Re: Sound delays with mixsdl
« Reply #7 on: June 09, 2006, 01:16:58 pm »

The machine is a AMD 2600+, 768MB of RAM.  The sound card is the onboard card:

Code:
$ cat /proc/asound/cards
 0 [SI7012         ]: ICH - SiS SI7012
                      SiS SI7012 with CMI9739 at 0xdc00, irq 17
OK, my laptop has an Intel chipset (ICH4) with the same sound driver (intel8x0), so I may be able to help. The relevant part of the UQM output is just like yours:
Code:
Initializing SDL audio subsystem.
SDL audio subsystem initialized.
Opening SDL audio device.
    using alsa at 44100 Hz 16 bit stereo, 940 samples audio buffer
However, I don't notice any sound latency anywhere. This is using SuSE 10.1 with SDL-1.2.9-19 and alsa-1.0.11-32. I can think of two possibilities:
  • The SDL sound latency issues described on the ALSA wiki page on the intel8x0.
  • You have dmix installed and it's introducing additional sound latency. What are the contents of your /etc/asound.conf or /etc/asound.state?

Edit: works for me with dmix enabled, too, although I suppose it is possible to mess up the configuration and cause latency.
« Last Edit: June 09, 2006, 05:25:46 pm by Novus » Logged

RTFM = Read the fine manual.
RTTFAQ = Read the Ur-Quan Masters Technical FAQ.
TigTigger
Zebranky food
*
Offline Offline

Posts: 41



View Profile
Re: Sound delays with mixsdl
« Reply #8 on: June 12, 2006, 03:44:03 am »

Thanks for your reply!

I can think of two possibilities:
  • The SDL sound latency issues described on the ALSA wiki page on the intel8x0.
  • You have dmix installed and it's introducing additional sound latency. What are the contents of your /etc/asound.conf or /etc/asound.state?

Here's the latter.  I have not changed them from the FC4 defauls.  I'll try to diddle with these sound settings, and see if anything helps.  Any chance of a SDL upgrade resolving this, I wonder...

Code:
$ cat /etc/asound.conf
# Generated by system-config-soundcard, do not edit by hand
defaults.pcm.card 0
defaults.pcm.card 0

... and asound.state is a bit large, so, I've posted it here:

http://sol.truespace.ca/Files/asound.state
Logged
Novus
Enlightened
*****
Offline Offline

Gender: Male
Posts: 1938


Fot or not?


View Profile
Re: Sound delays with mixsdl
« Reply #9 on: June 12, 2006, 09:15:35 am »

I can't find anything obviously wrong with your sound card settings that would cause this sort of problem. The only thing I can think of is upgrading ALSA and SDL and seeing if the problem goes away, or trying to find something in UQM that would account for this behaviour.
Logged

RTFM = Read the fine manual.
RTTFAQ = Read the Ur-Quan Masters Technical FAQ.
TigTigger
Zebranky food
*
Offline Offline

Posts: 41



View Profile
Re: Sound delays with mixsdl
« Reply #10 on: June 16, 2006, 06:37:06 pm »

I can't find anything obviously wrong with your sound card settings that would cause this sort of problem. The only thing I can think of is upgrading ALSA and SDL and seeing if the problem goes away, or trying to find something in UQM that would account for this behaviour.

I'll keep poking.  Thanks for everyone's help!

Logged
Pages: [1] Print 
« previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!