admin管理员组文章数量:1391918
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.
本文标签: cHow to get the name of IChannelControl from IntPtrStack Overflow
版权声明:本文标题:c# - How to get the name of IChannelControl from IntPtr? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744714352a2621313.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论