Detect Starvation in DSP

Hello! Im programming an ingame recording software. While video recording is working perfectly the audio isn’t. Our loading screen has incredible heavy CPU usage and game freezes sometimes, this produces Starvation ( [FMOD] OutputWASAPI::mixerThread : Starvation detected in WASAPI output buffer!) which results in shorter audio files. Is there any way to guarantee this starvation dont happen or even detect this starvation and how it affects the final audio file output?
Thanks in advance.

The code of my DSP is this

        private static RESULT CaptureDSPReadCallback(ref DSP_STATE dspState, IntPtr incomingBuffer, IntPtr outputBuffer, uint length,
            int incomingChannels, ref int outputChannels)
            DSP_STATE_FUNCTIONS functions = (DSP_STATE_FUNCTIONS)Marshal.PtrToStructure(dspState.functions, typeof(DSP_STATE_FUNCTIONS));
            functions.getuserdata(ref dspState, out IntPtr userData);

            GCHandle objHandle = GCHandle.FromIntPtr(userData);

            if (objHandle.Target is BugRecorder bugRecorder)
                // Save the channel count out for the update function
                bugRecorder._channels = incomingChannels;

                // Copy the incomingBuffer to process later
                int bufferLength = (int)length * incomingChannels;
                Marshal.Copy(incomingBuffer, bugRecorder._audioFrameDataBuffer, 0, bufferLength);

                // Copy the incomingBuffer to the outputBuffer so we can still hear it
                Marshal.Copy(bugRecorder._audioFrameDataBuffer, 0, outputBuffer, bufferLength);

                if (bugRecorder._isRecording)
                   bugRecorder.WriteAudioSampleToDisk(bugRecorder._audioFrameDataBuffer, bufferLength);

                return RESULT.OK;

            return RESULT.ERR_INTERNAL;


What version of FMOD are you using? Could you record a Profiler session and upload it to your profile with the following settings:
Please note you will have to register a project with us before you can upload files.

Instructions for connecting Live Update to Unity can be found here: Unity Integration | User Guide - Connecting Live Update.