Chaosforge Forum

  • April 19, 2024, 11:48
  • Welcome, Guest
Please login or register.



Login with username, password and session length
Pages: [1]

Author Topic: [0.9.9.3] Volume is muted when too many sounds play at once (includes a fix).  (Read 1496 times)

sklres

  • Lance Corporal
  • *
  • Offline Offline
  • Posts: 20
    • View Profile

I'm running DoomRL 0.9.9.3 on GNU/Linux (with sound). As far as I know, this bug does not happen on Windnows.

When DoomRL tries to play many sounds at once (e.g. when a lot of enemies are injured by a shotgun blast) the sound is either completely muted or cuts off abruptly. This makes radar shooting very hard on crowded levels and is generally very annoying (especially in the City of Skulls).

To see this in action download sound_test.lua into your DoomRL directory and run:
Code: [Select]
./doomrl -sandbox sound_test.luaYou will be placed into an empty level with 50 barons just out of your vision range. Fire a few shots to the right in quick succession and most (if not all) pain sounds will be muted.

There are a few problems:
  • DoomRL doesn't allocate enough channels. SDL_mixer only allocates 8 by default, which is not enough when you have 20-30 enemies making sounds.
  • DoomRL doesn't check the return value of Mix_PlayChannel() (when SDL_mixer runs out of channels, it returns -1). It then passes this value to Mix_Volume() and Mix_SetPanning(). Calling Mix_Volume(-1, ...) sets the volume of ALL channels.

This is what happens on the test level:
  • 50 barons are injured by a shotgun blast.
  • DoomRL tries to play 50 pain sounds at once and runs out of channels (only the first 8 are played).
  • One baron far to the right makes another sound (a howl or something).
  • DoomRL tries to play this sound, but it's too far to the right (volume=0) and there are no free channels (channel=-1), so it calls Mix_Volume(-1, 0) which mutes all sounds.

The fix is easy:
  • Check the return value of Mix_PlayChannel() and don't call Mix_Volume()/Mix_SetPanning() if it's -1.
  • After Mix_OpenAudio() call Mix_AllocateChannels() with a reasonable amount of channels (e.g. 100, maybe make it an option in the configuration file).
  • Don't call Mix_PlayChannel() if you're going to set the volume to 0 afterwards (this will save some channels).

Until this bug is fixed, you can use a small program to fix these issues. There is no guarantee that it will work, so backup your data before running it and don't whine if it formats your hard drive ;)

Download sound_fix.so into your DoomRL folder and run DoomRL like this:
Code: [Select]
LD_PRELOAD=./sound_fix.so ./doomrlor like this:
Code: [Select]
export LD_PRELOAD=./sound_fix.so
./doomrl

If you want to compile sound_fix.so from source, download sound_fix.tar.gz, unpack it and run `make' in the created directory - this will produce the sound_fix.so file (make sure you have g++, SDL and SDL_mixer development packages installed).

I hope this helps.
Logged
Pages: [1]