Do I have to call FMOD_Channel_RemoveDSP() and remove a DSP added to a channel with FMOD_Channel_AddDSP() after the sound stops?
I’m confused because FMOD_Channel_Stop() releases resources and invalidates the FMOD_CHANNEL handle.
That means FMOD_Channel_RemoveDSP() won’t work with my stale handle.
But as for FMOD_DSP_Release(), the document says :
“If DSP is not removed from the network with ChannelControl::removeDSP after being added with ChannelControl::addDSP, it will not release and will instead return FMOD_ERR_DSP_INUSE.”
Also, if I really have to remove the channel DSP, it’s a little bit annoying because I need to write extra code for that (like callbacks or checking logic if the sound stopped naturally or manually.).
So far, I mostly used global DSPs added to channel groups, but this time I need to add many different DSPs individually.
As part of stopping the channel, ChannelControl::stop automatically calls ChannelControl::removeDSP to remove all DSPs in the channel’s chain. You then need to call DSP::release on each of the DSPs to release them.
So, you do not have to call ChannelControl::removeDSP if you are stopping the channel with ChannelControl::stop, but you do need to call DSP::release for each DSP that you have created and added to the channel.
You can call me lazy, but is it safe just to call FMOD_Channel_RemoveDSP() on the stale channel handle regardless of the FMOD_RESULT error code returned by it, not thinking much about the state of the channel sound?
Yes, when a channel ends naturally, all DSPs in its chain are removed, as if you had called ChannelControl::stop.
The error code simply indicates that the channel handle is no longer valid, and that any operation on the associated channel will not do anything meaningful. Generating this error message won’t otherwise interfere with the running of your game - though of course, if your game’s intended behavior produces “false positive” error messages, anyone debugging your game will have to sort the meaningful error messages form the meaningless ones, and anyone reading those error messages without the context of this thread may assume that they represent unintended or buggy behavior in your game.