You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All wrapper sections completely ignore the RESULT value returned by the native library calls.
This makes it impossible to know if some call is not working, for example loading an event that does not exist or setting an invalid configuration, both very common and easy mistakes to make.
This does not only lead to user error, but also the very core wrapper is also not fully functional: for example in the FmodManager class there is a call to setDSPBufferSize that fails every single time, but since the result is not checked nobody saw the problem.
In the current state of the library, the first symptom of an FMOD call not working is typically a hard crash caused by a memory access violation, caused by the wrapper returning a reference to an invalid memory address when it should have checked the result before assuming that the pointer is valid.
I have forked this repo to make adjustments, and I can make a PR if it is wanted. In my fork, at a very minimum I will be adding the following:
/// <summary>/// An exception thrown when an FMOD function returns an error code./// </summary>publicsealedclassFModException:Exception{/// <summary>/// The result, containing the error code./// </summary>publicRESULTResult{get;}publicFModException(inRESULTresult,string?expression):base(expression==null?$"FMOD error: {FMOD.Error.String(result)}":$"FMOD error: {FMOD.Error.String(result)} ({expression})"){Result=result;}}// Helper extension method:internalstaticvoidThrowIfNotOk(thisRESULTresult,[CallerArgumentExpression(nameof(result))]stringcallerLine=""){if(result!=RESULT.OK)thrownewFModException(result,callerLine);}// Example usage:publicvoidLoadSampleData()=>Native.loadSampleData().ThrowIfNotOk();
The text was updated successfully, but these errors were encountered:
All wrapper sections completely ignore the
RESULT
value returned by the native library calls.This makes it impossible to know if some call is not working, for example loading an event that does not exist or setting an invalid configuration, both very common and easy mistakes to make.
This does not only lead to user error, but also the very core wrapper is also not fully functional: for example in the FmodManager class there is a call to
setDSPBufferSize
that fails every single time, but since the result is not checked nobody saw the problem.In the current state of the library, the first symptom of an FMOD call not working is typically a hard crash caused by a memory access violation, caused by the wrapper returning a reference to an invalid memory address when it should have checked the result before assuming that the pointer is valid.
I have forked this repo to make adjustments, and I can make a PR if it is wanted. In my fork, at a very minimum I will be adding the following:
The text was updated successfully, but these errors were encountered: