You are seeing an internal consistency check fail, could you provide a way to reproduce it?
Once we know the cause we will be better positioned to recommend workarounds or action a fix.
You mentioned that it ‘seems to happen after first song is opened from file’:
Is the song being played through a bank or ogg file?
Are you using any dsp effects on the song?
I have a dsp reading data all the time for FFT and visualization. Anything wrong here?
public KSDspCapture(ChannelGroup channelGroup)
{
// Assign the callback to a member variable to avoid garbage collection
readCallback = CaptureDSPReadCallback;
// Allocate a data buffer large enough for 8 channels, pin the memory to avoid garbage collection
// 8 channel * data for 8192 length
uint bufferLength;
RuntimeManager.CoreSystem.getDSPBufferSize(out bufferLength, out var _).Throw();
uint multi = (uint)math.ceil(8192f / bufferLength);
bufferLength = bufferLength * multi * 8;
buffer = new((int)bufferLength, Allocator.Persistent);
// Get a handle to this object to pass into the callback
// Define a basic DSP that receives a callback each mix to capture audio
DSP_DESCRIPTION desc = new DSP_DESCRIPTION();
desc.numinputbuffers = 1;
desc.numoutputbuffers = 1;
desc.read = readCallback;
RuntimeManager.CoreSystem.createDSP(ref desc, out captureDSP).Throw();
channelGroup.getDSP(CHANNELCONTROL_DSP_INDEX.HEAD, out var channelGroupDsp).Throw();
captureDSP.addInput(channelGroupDsp, out channelToCaptureConnection, DSPCONNECTION_TYPE.SEND_SIDECHAIN).Throw();
RuntimeManager.CoreSystem.getMasterChannelGroup(out var master).Throw();
master.getDSP(CHANNELCONTROL_DSP_INDEX.TAIL, out var masterTail).Throw(); //move this to before fader
masterTail.addInput(captureDSP, out var con, DSPCONNECTION_TYPE.SIDECHAIN);
captureDSP.setActive(true).Throw();
dspHandle = captureDSP.handle;
DspsLookup.Add(dspHandle, this);
The only thing that stands out is it looks like you aren’t passing a handle through the usedata of the FMOD.DSP_DESCRIPTION like we do in the DSP Capture example, although I assume your DspsLookup is taking care of that instead.
Are you able to trim down a project, that does the bare minimum to throw the error, which you are able to share with us? I have been unable to reproduce the issue here so far.