3 * @brief Common LibVLC objects marshalling utilities
7 /**********************************************************************
8 * Copyright (C) 2007-2009 RĂ©mi Denis-Courmont. *
9 * This program is free software; you can redistribute and/or modify *
10 * it under the terms of the GNU General Public License as published *
11 * by the Free Software Foundation; version 2 of the license, or (at *
12 * your option) any later version. *
14 * This program is distributed in the hope that it will be useful, *
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
17 * See the GNU General Public License for more details. *
19 * You should have received a copy of the GNU General Public License *
20 * along with this program; if not, you can get it from: *
21 * http://www.gnu.org/copyleft/gpl.html *
22 **********************************************************************/
25 using System.Runtime.InteropServices;
27 namespace VideoLAN.LibVLC
30 * @brief NonNullHandle: abstract safe handle class for non-NULL pointers
32 * Microsoft.* namespace has a similar class. However we want to use the
33 * System.* namespace only.
35 internal abstract class NonNullHandle : SafeHandle
37 protected NonNullHandle ()
38 : base (IntPtr.Zero, true)
43 * System.Runtime.InteropServices.SafeHandle::IsInvalid.
45 public override bool IsInvalid
49 return handle == IntPtr.Zero;
54 * Destroys an handle. Cannot fail.
56 protected abstract void Destroy ();
59 * System.Runtime.InteropServices.SafeHandle::ReleaseHandle.
61 protected override bool ReleaseHandle ()
70 * @brief BaseObject: generic wrapper around a safe LibVLC handle.
72 * This is the baseline for all managed LibVLC objects which wrap
73 * an unmanaged LibVLC pointer, and provides exception handling.
75 public class BaseObject : IDisposable
77 protected NativeException ex; /**< buffer for LibVLC exceptions */
78 protected SafeHandle handle; /**< wrapped safe handle */
80 internal BaseObject ()
82 ex = new NativeException ();
87 * Checks if the LibVLC run-time raised an exception
88 * If so, raises a CIL exception.
90 protected void Raise ()
96 * IDisposable::Dispose.
98 public void Dispose ()
101 GC.SuppressFinalize (this);
105 * Releases unmanaged resources associated with the object.
106 * @param disposing true if the disposing the object explicitly,
107 * false if finalizing the object inside the GC.
109 protected virtual void Dispose (bool disposing)