With this debug code, I was able to spot what I think must be a bug in the AGS sound system: If you try to play a clip when you've run out of AudioChannels for that AudioType, so that it has to preempt a currently playing clip, it actually stops all copies
of that clip (at least sometimes). This explains some weird behavior that a number of people have noticed but not been able to fully describe in the past (including bugs with the applause system in the AGS Awards Ceremony, and possibly the problems Monsieur OUXX was having that started this whole thing in the first place).
I'm using the two-click game template default game, and I've added this code in Room 1:
#define MAXCHANNELS_SOUND 5 // This matches the Sound AudioType setup
aBirthday.Play(eAudioPriorityHigh, eRepeat); // AudioType Sound
aLostCraftHowl.Play(eAudioPriorityHigh, eRepeat); // AudioType Sound
So each time I click on the TV, it starts playing another copy of one of the sound clips. The first five times, it correctly alternates between the two clips. But then on the sixth time (i.e. once we've run out of channels), things break. Usually, it will stop all the channels playing aLostCraftHowl (so you end up with three channels playing aBirthday and two playing nothing). Sometimes
it will do the right thing (stop only one of the channels), in particular after the first time: if you keep playing more clips, it won't (ever?) happen again even once you run out of the channels that were freed up by the clips that stopped playing, but if you stop all the clips and start over, it does recur.
I've tested a few variations. Most notably, the behavior differs if you switch the audio clips around, which indicates it has something to do with the clip itself. As far as I can tell, it has to do with the clip being preempted (not the one you're trying to play): in this case, preempting the clip aLostCraftHowl tends to stop all copies of the clip, while preempting aBirthday is (usually?) OK.
It doesn't matter whether the channel limit is set explicitly by MaxChannels or implicitly by how many are left over from other audio types. It doesn't matter if the clips are playing on eRepeat or eOnce.