Commit 354da4c5 authored by Martin Finkel's avatar Martin Finkel

Fix Utf8StringMarshaler usage for netstandard1.1

parent 7df56d4d
......@@ -9,12 +9,10 @@ namespace LibVLCSharp.Shared
{
internal struct Internal
{
[SuppressUnmanagedCodeSecurity]
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "libvlc_event_attach")]
internal static extern int LibVLCEventAttach(IntPtr eventManager, EventType eventType, EventCallback eventCallback,
IntPtr userData);
[SuppressUnmanagedCodeSecurity]
[DllImport(Constants.LibraryName, CallingConvention = CallingConvention.Cdecl, EntryPoint = "libvlc_event_detach")]
internal static extern void LibVLCEventDetach(IntPtr eventManager, EventType eventType, EventCallback eventCallback,
IntPtr userData);
......@@ -49,9 +47,9 @@ namespace LibVLCSharp.Shared
}
#if IOS
internal protected static LibVLCEvent RetrieveEvent(IntPtr eventPtr) => Marshal.PtrToStructure<LibVLCEvent>(eventPtr);
internal protected static LibVLCEvent RetrieveEvent(IntPtr eventPtr) => MarshalUtils.PtrToStructure<LibVLCEvent>(eventPtr);
#else
internal protected LibVLCEvent RetrieveEvent(IntPtr eventPtr) => Marshal.PtrToStructure<LibVLCEvent>(eventPtr);
internal protected LibVLCEvent RetrieveEvent(IntPtr eventPtr) => MarshalUtils.PtrToStructure<LibVLCEvent>(eventPtr);
#endif
internal protected void OnEventUnhandled(object sender, EventType eventType)
......@@ -61,6 +59,6 @@ namespace LibVLCSharp.Shared
internal protected abstract void DetachEvent<T>(EventType eventType, EventHandler<T> eventHandler) where T : EventArgs;
}
[SuppressUnmanagedCodeSecurity, UnmanagedFunctionPointer(CallingConvention.Cdecl)]
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void EventCallback(IntPtr args);
}
\ No newline at end of file
......@@ -76,7 +76,11 @@ namespace LibVLCSharp.Shared
{
const int VideoRenderer = 0x0002;
const int AudioRenderer = 0x0001;
#if NETSTANDARD1_1
readonly Utf8StringMarshaler _utf8Marshaler = Utf8StringMarshaler.GetInstance();
#else
readonly ICustomMarshaler _utf8Marshaler = Utf8StringMarshaler.GetInstance();
#endif
struct Native
{
......
......@@ -11,6 +11,9 @@ namespace LibVLCSharp.Shared
/// </summary>
#if !NETSTANDARD1_1
public class Utf8StringMarshaler : ICustomMarshaler
#else
public class Utf8StringMarshaler
#endif
{
private static readonly Utf8StringMarshaler _instance = new Utf8StringMarshaler();
......@@ -59,11 +62,13 @@ namespace LibVLCSharp.Shared
{
return -1;
}
#if !NETSTANDARD1_1
public static ICustomMarshaler GetInstance(string cookie = null)
#else
public static Utf8StringMarshaler GetInstance()
#endif
{
return _instance;
}
}
#endif
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment