c# - How to get the name of IChannelControl from IntPtr? - Stack Overflow

I have registered a callback to get errors that looks like this and I am trying to get the name of the

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.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744714353a4589528.html

相关推荐

  • c# - How to get the name of IChannelControl from IntPtr? - Stack Overflow

    I have registered a callback to get errors that looks like this and I am trying to get the name of the

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信