1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-25 06:05:45 +00:00

Little hack to bring audio thread creation down.

Do not play sounds with volume 0 that would never get audible.
This helps against stuttering on maps with many entities that play
sounds in regular intervals, but are too far away to be heard.
This needs to be removed once audio position updating is implemented.
This commit is contained in:
fgenesis 2012-02-06 19:54:28 +01:00
parent 1d12576322
commit ed767d150b
2 changed files with 19 additions and 0 deletions

View file

@ -2208,6 +2208,16 @@ void DSQ::playPositionalSfx(const std::string &name, const Vector &position, flo
{
PlaySfx sfx = calcPositionalSfx(position);
// FIXME: Right now, positional sound effects never update their relative position to the
// listener, which means that if they are spawned too far away to be audible, it is not possible
// that they ever get audible at all. Additionally, the current scripting API only provides
// functions to fade sounds OUT, not to set their volume arbitrarily.
// Because audio thread creation is costly, drop sounds that can not be heard.
// This needs to be removed once proper audio source/listener positioning is implemented,
// or the scripting interface gets additional functions to mess with sound. -- FG
if (sfx.vol <= 0)
return;
sfx.freq = f;
sfx.name = name;

View file

@ -2346,6 +2346,11 @@ luaFunc(entity_playSfx)
float fadeOut = lua_tonumber(L, 6);
if(vol > 0)
sfx.vol *= vol;
// FIXME: See comment in DSQ::playPositionalSfx() -- FG
if (sfx.vol <= 0)
luaReturnPtr(NULL);
h = core->sound->playSfx(sfx);
if (fadeOut != 0)
{
@ -5136,6 +5141,10 @@ luaFunc(playSfx)
sfx.vol = vol;
}
// FIXME: See comment in DSQ::playPositionalSfx() -- FG
if (sfx.vol <= 0)
luaReturnPtr(NULL);
sfx.name = getString(L, 1);
sfx.freq = freq;
sfx.loops = loops;