It occurred also to me today , and luckily enough it happened during a debug session. I was passing from one train to another with the Alt-9 command: the crash occurred in the updater process during these instructions of TrainCar.cs (#1453), and in particular in the first OpenAL... instruction:
var soundSourceIDs = SoundSourceIDs.ToArray(); foreach (var soundSourceID in soundSourceIDs) { OpenAL.alSourcefv(soundSourceID, OpenAL.AL_POSITION, position); OpenAL.alSourcefv(soundSourceID, OpenAL.AL_VELOCITY, Velocity); }
At the moment of the crash there are three soundSourceIDs: 47, 48 and 49.
As I was in debug I could check what the sound process was doing at the same moment: it was in line 628 (it's the third OpenAL... line) of ALSoundHelper.cs, within this block:
if (Ignore3D) { OpenAL.alSourcei(SoundSourceID, OpenAL.AL_SOURCE_RELATIVE, OpenAL.AL_TRUE); OpenAL.alSourcef(SoundSourceID, OpenAL.AL_DOPPLER_FACTOR, 0); OpenAL.alSource3f(SoundSourceID, OpenAL.AL_POSITION, 0, 0, 0); OpenAL.alSource3f(SoundSourceID, OpenAL.AL_VELOCITY, 0, 0, 0); }
At the moment of the crashe the SoundSourceID is 55, so one not existing within soundSourceIDs.
so there is a conflict in dealing with a SoundSourceID. Again, moving the SoundSourceIDs in a new array as done in TrainCar.cs does not seem to solve the problem.
Solutions, apart another lock, that James does not like? Am I authorized to insert a lock? Would it be better to move the loop from TrainCar.cs to the sound process?