static void OverrideAlloc(GLib.GType gtype, AllocNativeDelegate callback)
 {
     unsafe {
         IntPtr *raw_ptr = (IntPtr *)(((long)gtype.GetClassPtr()) + (long)class_abi.GetFieldOffset("alloc"));
         *raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate)callback);
     }
 }
Example #2
0
        private Gst.FlowReturn InternalAlloc(Gst.Buffer buf)
        {
            AllocNativeDelegate unmanaged = null;

            unsafe {
                IntPtr *raw_ptr = (IntPtr *)(((long)this.LookupGType().GetThresholdType().GetClassPtr()) + (long)class_abi.GetFieldOffset("alloc"));
                unmanaged = (AllocNativeDelegate)Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(AllocNativeDelegate));
            }
            if (unmanaged == null)
            {
                return((Gst.FlowReturn) 0);
            }

            int __result = unmanaged(this.Handle, buf == null ? IntPtr.Zero : buf.Handle);

            return((Gst.FlowReturn)__result);
        }
        private Gst.Memory InternalAlloc(ulong size, Gst.AllocationParams parms)
        {
            AllocNativeDelegate unmanaged = null;

            unsafe {
                IntPtr *raw_ptr = (IntPtr *)(((long)this.LookupGType().GetThresholdType().GetClassPtr()) + (long)class_abi.GetFieldOffset("alloc"));
                unmanaged = (AllocNativeDelegate)Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(AllocNativeDelegate));
            }
            if (unmanaged == null)
            {
                return(null);
            }

            IntPtr native_parms = GLib.Marshaller.StructureToPtrAlloc(parms);
            IntPtr __result     = unmanaged(this.Handle, new UIntPtr(size), native_parms);

            Marshal.FreeHGlobal(native_parms);
            return(__result == IntPtr.Zero ? null : (Gst.Memory)GLib.Opaque.GetOpaque(__result, typeof(Gst.Memory), true));
        }