I’m getting the starvation warning from the following code run in unity specifically on ending playmode. No actual audio needs to be played.
using System;
using FMOD;
using FMODUnity;
using UnityEngine;
class ExactExample : MonoBehaviour
{
private DSP mCaptureDSP;
private uint mBufferLength;
private int mChannels = 0;
void Start()
{
DSP_DESCRIPTION desc = new DSP_DESCRIPTION
{
numinputbuffers = 1,
numoutputbuffers = 1,
// most other callbacks will not produce the starvation warning
// although process callback fires a raw exception even when empty
read = CaptureDSPReadCallback
};
RuntimeManager.CoreSystem.getMasterChannelGroup( out var masterCG );
RuntimeManager.CoreSystem.createDSP( ref desc, out mCaptureDSP );
masterCG.addDSP( 0, mCaptureDSP );
}
[AOT.MonoPInvokeCallback( typeof(DSP_READ_CALLBACK) )]
static RESULT CaptureDSPReadCallback( ref DSP_STATE dsp_state, IntPtr inbuffer, IntPtr outbuffer, uint length, int inchannels, ref int outchannels )
{
return RESULT.OK;
}
private void OnDisable()
{
if( mCaptureDSP.hasHandle() )
{
if( RuntimeManager.CoreSystem.getMasterChannelGroup( out var channelGroup ) == RESULT.OK )
channelGroup.removeDSP( mCaptureDSP );
mCaptureDSP.release();
mCaptureDSP.clearHandle();
}
}
}
If the read callback is set, the warning will fire when exiting playmode.
I’ve tried a bunch of variations. None will prevent the warning on shutdown.
Worth noting that assigning the process callback will throw a marshal type exception and lock the editor:
[AOT.MonoPInvokeCallback( typeof(DSP_PROCESS_CALLBACK) )]
private RESULT ProcessCallback( ref DSP_STATE dsp_state, uint length, ref DSP_BUFFER_ARRAY inbufferarray, ref DSP_BUFFER_ARRAY outbufferarray, bool inputsidle, DSP_PROCESS_OPERATION op )
{
return RESULT.OK;
}
.....
MarshalDirectiveException: Structure field of type Int32[] can't be marshalled as LPArray
at (wrapper native-to-managed) ExactExample.ProcessCallback(FMOD.DSP_STATE&,uint,FMOD.DSP_BUFFER_ARRAY&,FMOD.DSP_BUFFER_ARRAY&,int,FMOD.DSP_PROCESS_OPERATION)
Super annoying.
Am I doing something incredibly wrong here or is this just a bug in fmod’s unity api?
NOTE: Tested with an older project and the starvation warning does not happen with 2.02.15 it does happen with 2.02.22.
This is a crosspost in the hopes of getting an actual response.