Back to development
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / GstSharp.PadProbeCallbackNative.cs
1 // This file was generated by the Gtk# code generator.
2 // Any changes made will be lost if regenerated.
3
4 namespace GstSharp {
5
6         using System;
7         using System.Runtime.InteropServices;
8
9 #region Autogenerated code
10         [UnmanagedFunctionPointer (CallingConvention.Cdecl)]
11         internal delegate int PadProbeCallbackNative(IntPtr pad, IntPtr info, IntPtr user_data);
12
13         internal class PadProbeCallbackInvoker {
14
15                 PadProbeCallbackNative native_cb;
16                 IntPtr __data;
17                 GLib.DestroyNotify __notify;
18
19                 ~PadProbeCallbackInvoker ()
20                 {
21                         if (__notify == null)
22                                 return;
23                         __notify (__data);
24                 }
25
26                 internal PadProbeCallbackInvoker (PadProbeCallbackNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
27
28                 internal PadProbeCallbackInvoker (PadProbeCallbackNative native_cb, IntPtr data) : this (native_cb, data, null) {}
29
30                 internal PadProbeCallbackInvoker (PadProbeCallbackNative native_cb, IntPtr data, GLib.DestroyNotify notify)
31                 {
32                         this.native_cb = native_cb;
33                         __data = data;
34                         __notify = notify;
35                 }
36
37                 internal Gst.PadProbeCallback Handler {
38                         get {
39                                 return new Gst.PadProbeCallback(InvokeNative);
40                         }
41                 }
42
43                 Gst.PadProbeReturn InvokeNative (Gst.Pad pad, Gst.PadProbeInfo info)
44                 {
45                         IntPtr native_info = GLib.Marshaller.StructureToPtrAlloc (info);
46                         Gst.PadProbeReturn __result = (Gst.PadProbeReturn) native_cb (pad == null ? IntPtr.Zero : pad.Handle, native_info, __data);
47                         Marshal.FreeHGlobal (native_info);
48                         return __result;
49                 }
50         }
51
52         internal class PadProbeCallbackWrapper {
53
54                 public int NativeCallback (IntPtr pad, IntPtr info, IntPtr user_data)
55                 {
56                         try {
57                                 Gst.PadProbeReturn __ret = managed (GLib.Object.GetObject(pad) as Gst.Pad, Gst.PadProbeInfo.New (info));
58                                 if (release_on_call)
59                                         gch.Free ();
60                                 return (int) __ret;
61                         } catch (Exception e) {
62                                 GLib.ExceptionManager.RaiseUnhandledException (e, true);
63                                 // NOTREACHED: Above call does not return.
64                                 throw e;
65                         }
66                 }
67
68                 bool release_on_call = false;
69                 GCHandle gch;
70
71                 public void PersistUntilCalled ()
72                 {
73                         release_on_call = true;
74                         gch = GCHandle.Alloc (this);
75                 }
76
77                 internal PadProbeCallbackNative NativeDelegate;
78                 Gst.PadProbeCallback managed;
79
80                 public PadProbeCallbackWrapper (Gst.PadProbeCallback managed)
81                 {
82                         this.managed = managed;
83                         if (managed != null)
84                                 NativeDelegate = new PadProbeCallbackNative (NativeCallback);
85                 }
86
87                 public static Gst.PadProbeCallback GetManagedDelegate (PadProbeCallbackNative native)
88                 {
89                         if (native == null)
90                                 return null;
91                         PadProbeCallbackWrapper wrapper = (PadProbeCallbackWrapper) native.Target;
92                         if (wrapper == null)
93                                 return null;
94                         return wrapper.managed;
95                 }
96         }
97 #endregion
98 }