Closed a1exsh closed 2 years ago
Hi @a1exsh if this issue is reliably reproducible with your setup, it would be nice to perform a git bisect
to find commit that introduced it.
Hi @a1exsh , is it still reproducible on the latest commit from master?
Hi @a1exsh , is it still reproducible on the latest commit from master?
Yep. Just built cleanly from 8a25c0d3 and I can reproduce it after a few minutes playing the attached save file. So far I've noticed it being triggered when a hero is moving over a road or a river, but this doesn't always logs this error.
It looks like this is not caused by recent changes in fheroes2, but by some update of libraries on my system. I've checked a number of sound-related changes and went as early as to the previous release 0.9.8 and the issue is still reproducible.
I was able to reproduce the error on a different machine with Ubuntu 21.10, by building from HEAD as of today.
I think if you're playing a map where a hero is surrounded by more than 16 objects this error appears.
I think if you're playing a map where a hero is surrounded by more than 16 objects this error appears.
Ah, that's a good guess. I wonder can we do something to prevent this? We track the channels ourselves, if I'm not mistaken, so we could avoid playing an extra sound when all channels are busy and log a debug message instead?
We track the channels ourselves, if I'm not mistaken, so we could avoid playing an extra sound when all channels are busy and log a debug message instead?
That's what in fact happens here: extra sound is not played and the message is logged :) We can also try to increase the number of channels.
That's what in fact happens here: extra sound is not played and the message is logged
Yes, but an ERROR message is logged, as if something unexpected has happened. I'd prefer this to be a debug message that we can ignore, instead of starting to ignore errors.
Yes, but an ERROR message is logged, as if something unexpected has happened.
This is really a bit unexpected. However, it seems that maximum number of channels in Mix_AllocateChannels()
depends just on available RAM and not on some audio hardware limitations, so we can try to just increase number of channels from 16 to, say, 32 here:
You can try it yourself and see is this solves an issue.
increase number of channels from 16 to, say, 32
I'd rather not do that: 16 sounds at once is probably already too much — adding more will likely result in the player hearing just noise.
Maybe we should consider less object in the hero's vicinity? How did we came to use all 16 channels in the first place?
Originally this number was 8. Then we increased it to 16. What we need to do is to limit the number of objects from where we play sounds. There's a function to scan nearby objects around a hero and then play sounds from them according to distance. We need to modify that part. The current implementation simply doesn't take into account that 2 objects might have the same sound and it doesn't check if the object is near than another one.
The environment sound mixer scans 7x7 area around a hero or castle to find objects with ambient sounds, and the farther the object is from the hero or castle, the lower the volume. It would be interesting though to try to increase number of channels and hear the result in the cases where all these "no free channels" messages arrive.
The current implementation simply doesn't take into account that 2 objects might have the same sound
Well, that's not necessarily bad, as in stereo the sounds may be coming from different directions. I don't immediately see why we should change this part.
and it doesn't check if the object is near than another one
That. I guess we are just considering an area too big to be relevant (the farthest objects occupying the channels, but producing sounds to quiet to be noticable). What if we sort objects by distance before playing the sounds — closest first?
Yes, closest objects should be first.
Hi @a1exsh and @oleg-derevenetz , please take a look at #4706.
@ihhub This error message wasn't appearing for a while, but now I'm constantly seeing it again after building from HEAD
...
Hi @a1exsh Is there any way to attach a savefile with instructions on how to reproduce this (so that at least on your system it was 100% reproducible)? Something like "load this savefile and move Roxana 3 tiles to the right"?
@oleg-derevenetz @ihhub hm, I cannot reproduce it anymore after another clean build from HEAD... sorry for the noise: it must be some artifact of checking out other branches. I need to rest more ;)
Sorry, I have to re-open this, but this time I've got a reproducer! :)
This time the error is logged when in the battle:
Aha. Although this message does not appear to me, I can assume the mechanism of its appearance. When a sufficiently high animation speed is selected, some unit sounds (for example, footsteps) overlap each other, and the new sound starts playing before the old one finishes playing. Thus, many identical sounds can be played simultaneously (creating a some sort of a rush effect) and many sound channels can be busy playing those sounds. This is mostly harmless.
Sure, I understand that it's harmless, so maybe we should demote it to a warning or even a debug message? Otherwise it may make it easy to miss real errors.
As for me, I'd rather increase the number of channels (from 16 to, say, 32) :) AFAIK this costs just a some amount of RAM, nothing more.
Preliminary checks
Platform
Linux
Describe the bug
In a version built from recent
HEAD
the following errors appear on the console:This was not the case until recently.
Save file
Not sure what triggers it. Will add a save file if I find when the error appears.
Additional info
Haven't noticed any sounds missing so far.