I’m writing a system to forward all of the audio coming out of FMOD to FFMPEG, for video recording. Right now I have achieved this with a custom DSP attached to the tail of the master channel group. Functionally, everything works, except that after this DSP is added, at the end of gameplay I get a starvation warning and an audible ‘pop’, when the FMOD core system shuts down.
Here are the minimal reproduction steps for me:
- At the start of the game, add a custom DSP, with an empty C# callback.
- At frame 5, remove and release the custom DSP.
- At frame 5000, the game ends, and I hear a pop, and get a starvation warning.
Is there some reason that having an empty C# DSP attached to the master group might cause a delay? I can’t imagine why I see this issue at the end of the game, even though the DSP is long gone (removed on frame 5). I’ve confirmed it’s removed properly using the FMOD Core Profiler.
Here’s my code. Is there a better way to read audio out of the master bus? Ideally, I would like my reading to be asynchronous, but as far as I can tell, there’s no way to achieve that?
var dspDescription = new DSP_DESCRIPTION
{
version = 0x00010000,
name = dspName,
numinputbuffers = 1,
numoutputbuffers = 1,
read = DspReadCallback,
numparameters = 0
};
// Get the master group and read the channel settings.
FMOD.System system = RuntimeManager.CoreSystem;
CheckError(system.getMasterChannelGroup(out ChannelGroup masterGroup));
CheckError(masterGroup.getDSP(CHANNELCONTROL_DSP_INDEX.TAIL, out DSP masterDspTail));
CheckError(masterDspTail.getChannelFormat(out CHANNELMASK channelMask, out int numChannels, out SPEAKERMODE sourceSpeakerMode));
// Create a new DSP with the format of the existing master group.
CheckError(system.createDSP(ref dspDescription, out dsp));
CheckError(dsp.setChannelFormat(channelMask, numChannels, sourceSpeakerMode));
CheckError(masterGroup.addDSP(CHANNELCONTROL_DSP_INDEX.TAIL, dsp));
// ...
// Copy audio into buffer. Issue appears, even if this function is empty.
private RESULT DspReadCallback(ref DSP_STATE dsp_state, IntPtr inbuffer, IntPtr outbuffer, uint samples, int inchannels, ref int outchannels)