int mpv_render_context_create(mpv_render_context **res, mpv_handle *mpv, mpv_render_param *params);
The problem is, that I have no clue how to call the function from C#. [StructLayout(LayoutKind.Sequential)]
public unsafe struct MpvRenderParam
{
public MpvRenderParamType Type;
public void* Data;
}
IntPtr
but in my opinion it makes more sense when it can be an all purpose pointer, so it matches the definition of the C Library. public enum MpvRenderParamType
{
Invalid = 0,
ApiType = 1,
InitParams = 2,
Fbo = 3,
FlipY = 4,
Depth = 5,
IccProfile = 6,
AmbientLight = 7,
X11Display = 8,
WlDisplay = 9,
AdvancedControl = 10,
NextFrameInfo = 11,
BlockForTargetTime = 12,
SkipRendering = 13,
DrmDisplay = 14,
DrmDrawSurfaceSize = 15,
DrmDisplayV2 = 15
}
[DllImport("mpv-1.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int mpv_render_context_create([Out] out IntPtr renderContext, IntPtr mpvHandle,
MpvRenderParam[] parameters);
var ptr = IntPtr.Zero;
var apiTypePtr = Marshal.StringToHGlobalAuto("opengl");
var i = mpv_render_context_create(out ptr, _mpvHandle, new []
{
new MpvRenderParam(MpvRenderParamType.ApiType, apiTypePtr),
new MpvRenderParam(MpvRenderParamType.Invalid, IntPtr.Zero
});
Exception thrown at 0x0000000055C73D60 (mpv-1.dll) in Otchi.App.exe: 0xC0000005: Access violation reading location 0x0000000000000010.My last attempt was going into the unsafe part of C# and declaring the method like this:
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
private static extern unsafe int mpv_render_context_create(IntPtr* renderContext, IntPtr mpvHandle,
MpvRenderParam[] parameters);
IntPtr ptr;
var test = GCHandle.Alloc("opengl");
var test2 = GCHandle.ToIntPtr(test);
var apiTypePtr = Marshal.StringToHGlobalAuto("opengl");
var i = mpv_render_context_create(&ptr, _mpvHandle, new []
{
new MpvRenderParam{Type = MpvRenderParamType.ApiType, Data = &apiTypePtr},
new MpvRenderParam{Type = MpvRenderParamType.Invalid, Data = null}
});
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.