0

I have registered a callback to get errors that looks like this and I am trying to get the name of the callbackInfo.instance to debug it but callbackInfo.instancetype is a ERRORCALLBACK_INSTANCETYPE.CHANNELCONTROL and reading the docs it corresponds to an IChannelControl interface which can be either a Channel or a ChannelGroup and I cant figure out a way to determine which one it actually is and if I chose wrong all I get is garbage.

var errorCallback = new FMOD.SYSTEM_CALLBACK(ERROR_CALLBACK);
system.setCallback(errorCallback, FMOD.SYSTEM_CALLBACK_TYPE.ERROR);

private static FMOD.RESULT ERROR_CALLBACK(IntPtr system, FMOD.SYSTEM_CALLBACK_TYPE type, IntPtr commanddata1, IntPtr commanddata2, IntPtr userdata)
{
    FMOD.ERRORCALLBACK_INFO callbackInfo = Marshal.PtrToStructure<FMOD.ERRORCALLBACK_INFO>(commanddata1);

    if(callbackInfo.instancetype == ERRORCALLBACK_INSTANCETYPE.CHANNELGROUP)
    {
        // get the name or other identifier of the callbackInfo.instance
    }
}

So I either need a way to determine which type it is or a way to get the name without knowing the type.

Edit 1: To clarify, both Channel and ChannelGroup have constructors that take an IntPtr, thats the only way i have found to actually create those objects. Marshalling like is done above for the ERRORCALLBACK_INFO does not work since the structs dont have any actual data and is just a wrapper for a c++ object.

3
  • IntPtr is usually a memory address pointer, to a variable/structure, you would then read that address in the form of the structure to retrieve any info in it Commented Mar 13 at 10:59
  • @BugFinder I have added a clarification, do you know any way to do this in this case. Commented Mar 13 at 12:53
  • An intptr isnt a wrapper. Its a pointer. However i dont use fmod Commented Mar 13 at 14:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.