sound: Increase the mixer channel allocation from 16 to 32

This raises the sound effect (SOUND_FX) channel group size from 5 to
21.

The rationale for this change is that the current SFX channel group size
is not enough in some situations (particularly during cutscenes and with
accelerated animations enabled), and decreasing the channel group size
for sound sources (currently 8, preserved as-is in this commit) doesn't
seem like the best solution at this point considering that the sound
source feature is neglected enough as it is. Three other channels are
reserved for the turn bell, turn timer countdown sound, and UI sounds,
and it'd be an even worse idea to drop those.

The SDL_mixer documentation suggests that increased mixer channel
allocations may be a memory usage concern with a high number of channels
("We're talking REALLY high!", their words), but hopefully this small
increase is good enough for our and the UMC making community's purposes
without impacting memory usage or performance on our main supported
platforms. At least Wesnoth's RSS didn't seem to change over a megabyte
when testing this patch on Linux (using ALSA).

Note:

Should this increased limit cause issues on some platform that matters
(hopefully not!) an alternative would be to reengineer the sound channel
selection done in sound::play_sound_internal() so instead of skipping
sounds when all channels are busy, the oldest playing channel is stopped
and reset to the requested sound, for channels in the SOUND_FX group.
However, this seems too complicated to do at this point for 1.12, so yet
another alternative would be to simply reduce the number of channels
reserved for sound sources and give those back to SOUND_FX.
This commit is contained in:
Ignacio R. Morelle 2014-03-15 01:22:20 -03:00
parent faaad1991b
commit 0763670a3f
2 changed files with 4 additions and 2 deletions

View file

@ -23,6 +23,8 @@ Version 1.13.0-dev:
* Idle controlled sides now serialize as human controlled.
* Fixed bug #20876: A segfault in cut_surface.
* Changed: Dropped support for AmigaOS, BeOS, and OS/2.
* Increased the sound mixer channel allocation from 16 to 32, thereby
raising the limit for simultaneous sound effects from 5 to 21.
Version 1.11.11:
* Add-ons server:

View file

@ -57,14 +57,14 @@ int fadingout_time=5000;
bool no_fading = false;
// number of allocated channels,
const size_t n_of_channels = 16;
const size_t n_of_channels = 32;
// we need 2 channels, because we it for timer as well
const size_t bell_channel = 0;
const size_t timer_channel = 1;
// number of channels reserved for sound sources
const size_t source_channels = n_of_channels - 8;
const size_t source_channels = 8;
const size_t source_channel_start = timer_channel + 1;
const size_t source_channel_last = source_channel_start + source_channels - 1;
const size_t UI_sound_channel = source_channel_last + 1;