/* * libvlc.cs - libvlc-control CIL bindings * * $Id$ */ /********************************************************************** * Copyright (C) 2007 RĂ©mi Denis-Courmont. * * This program is free software; you can redistribute and/or modify * * it under the terms of the GNU General Public License as published * * by the Free Software Foundation; version 2 of the license, or (at * * your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * * See the GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, you can get it from: * * http://www.gnu.org/copyleft/gpl.html * **********************************************************************/ using System; using System.Runtime.InteropServices; namespace VideoLAN.LibVLC { /** * VLCException: managed base class for LibVLC exceptions */ public class VLCException : Exception { public VLCException () { } public VLCException (string message) : base (message) { } public VLCException (string message, Exception inner) : base (message, inner) { } }; /** * libvlc_exception_t: structure for unmanaged LibVLC exceptions */ [StructLayout (LayoutKind.Sequential)] public sealed class NativeException : IDisposable { int raised; int code; IntPtr message; [DllImport ("libvlc-control.dll", EntryPoint="libvlc_exception_init")] static extern void Init (NativeException e); [DllImport ("libvlc-control.dll", EntryPoint="libvlc_exception_clear")] static extern void Clear (NativeException e); /*[DllImport ("libvlc-control.dll", EntryPoint="libvlc_exception_raised")] static extern int Raised (NativeException e);*/ [DllImport ("libvlc-control.dll", EntryPoint="libvlc_exception_get_message")] static extern IntPtr GetMessage (NativeException e); public NativeException () { Init (this); } public void Raise () { try { string msg = U8String.FromNative (GetMessage (this)); if (msg != null) throw new VLCException (msg); } finally { Clear (this); } } public void Dispose () { Clear (this); } }; };