我尝试在线搜索我的问题的答案无济于事。
我有一个带有以下结构和方法的C / C ++ DLL:
typedef struct AVPacket {
int64_t pts;
int64_t dts;
uint8_t *data;
int size;
int stream_index;
int flags;
int duration;
void (*destruct) (struct AVPacket *);
void *priv;
int64_t pos;
} AVPacket;
typedef AVPacket * HAVPacket;
HAVPacket __stdcall ffCreateAVPacket(bool fillWithZero);
现在我的C#代码如下所示:
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct AVPacket
{
public Int64 pts;
public Int64 dts;
public byte[] data;
public int size;
public int stream_index;
public int flags;
public int duration;
public IntPtr destruct;
public IntPtr priv;
public Int64 pos;
}
[DllImport(dll, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
static extern void ffCreateAVPacket(bool fillWithZero, out AVPacket packet);
我打电话使用:
AVPacket packet;
ffCreateAVPacket(true, out packet);
我收到一个PInvokeStackImbalance异常说明:对PInvoke的调用使堆栈失去平衡。
非常感谢任何帮助。
问候。