Release 1.22.7
[platform/upstream/gstreamer.git] / subprojects / gstreamer-sharp / sources / generated / Gst / GstSharp.BufferListFuncNative.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 bool BufferListFuncNative(out IntPtr buffer, uint idx, IntPtr user_data);
12
13         internal class BufferListFuncInvoker {
14
15                 BufferListFuncNative native_cb;
16                 IntPtr __data;
17                 GLib.DestroyNotify __notify;
18
19                 ~BufferListFuncInvoker ()
20                 {
21                         if (__notify == null)
22                                 return;
23                         __notify (__data);
24                 }
25
26                 internal BufferListFuncInvoker (BufferListFuncNative native_cb) : this (native_cb, IntPtr.Zero, null) {}
27
28                 internal BufferListFuncInvoker (BufferListFuncNative native_cb, IntPtr data) : this (native_cb, data, null) {}
29
30                 internal BufferListFuncInvoker (BufferListFuncNative 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.BufferListFunc Handler {
38                         get {
39                                 return new Gst.BufferListFunc(InvokeNative);
40                         }
41                 }
42
43                 bool InvokeNative (out Gst.Buffer buffer, uint idx)
44                 {
45                         IntPtr native_buffer;
46                         bool __result = native_cb (out native_buffer, idx, __data);
47                         buffer = native_buffer == IntPtr.Zero ? null : (Gst.Buffer) GLib.Opaque.GetOpaque (native_buffer, typeof (Gst.Buffer), true);
48                         return __result;
49                 }
50         }
51
52         internal class BufferListFuncWrapper {
53
54                 public bool NativeCallback (out IntPtr buffer, uint idx, IntPtr user_data)
55                 {
56                         try {
57                                 Gst.Buffer mybuffer;
58
59                                 bool __ret = managed (out mybuffer, idx);
60                                 buffer = mybuffer == null ? IntPtr.Zero : mybuffer.Handle;
61
62                                 if (release_on_call)
63                                         gch.Free ();
64                                 return __ret;
65                         } catch (Exception e) {
66                                 GLib.ExceptionManager.RaiseUnhandledException (e, true);
67                                 // NOTREACHED: Above call does not return.
68                                 throw e;
69                         }
70                 }
71
72                 bool release_on_call = false;
73                 GCHandle gch;
74
75                 public void PersistUntilCalled ()
76                 {
77                         release_on_call = true;
78                         gch = GCHandle.Alloc (this);
79                 }
80
81                 internal BufferListFuncNative NativeDelegate;
82                 Gst.BufferListFunc managed;
83
84                 public BufferListFuncWrapper (Gst.BufferListFunc managed)
85                 {
86                         this.managed = managed;
87                         if (managed != null)
88                                 NativeDelegate = new BufferListFuncNative (NativeCallback);
89                 }
90
91                 public static Gst.BufferListFunc GetManagedDelegate (BufferListFuncNative native)
92                 {
93                         if (native == null)
94                                 return null;
95                         BufferListFuncWrapper wrapper = (BufferListFuncWrapper) native.Target;
96                         if (wrapper == null)
97                                 return null;
98                         return wrapper.managed;
99                 }
100         }
101 #endregion
102 }