Пример #1
0
 /// <summary>
 /// <para>Create and initialize a libvlc instance.</para>
 /// <para>This functions accept a list of &quot;command line&quot; arguments similar to the</para>
 /// <para>main(). These arguments affect the LibVLC instance default configuration.</para>
 /// </summary>
 /// <param name="argc">the number of arguments (should be 0)</param>
 /// <param name="args">list of arguments (should be NULL)</param>
 /// <returns>the libvlc instance or NULL in case of error</returns>
 /// <remarks>
 /// <para>LibVLC may create threads. Therefore, any thread-unsafe process</para>
 /// <para>initialization must be performed before calling libvlc_new(). In particular</para>
 /// <para>and where applicable:</para>
 /// <para>- setlocale() and textdomain(),</para>
 /// <para>- setenv(), unsetenv() and putenv(),</para>
 /// <para>- with the X11 display system, XInitThreads()</para>
 /// <para>(see also libvlc_media_player_set_xwindow()) and</para>
 /// <para>- on Microsoft Windows, SetErrorMode().</para>
 /// <para>- sigprocmask() shall never be invoked; pthread_sigmask() can be used.</para>
 /// <para>On POSIX systems, the SIGCHLD signalmust notbe ignored, i.e. the</para>
 /// <para>signal handler must set to SIG_DFL or a function pointer, not SIG_IGN.</para>
 /// <para>Also while LibVLC is active, the wait() function shall not be called, and</para>
 /// <para>any call to waitpid() shall use a strictly positive value for the first</para>
 /// <para>parameter (i.e. the PID). Failure to follow those rules may lead to a</para>
 /// <para>deadlock or a busy loop.</para>
 /// <para>Also on POSIX systems, it is recommended that the SIGPIPE signal be blocked,</para>
 /// <para>even if it is not, in principles, necessary, e.g.:</para>
 /// <para>On Microsoft Windows Vista/2008, the process error mode</para>
 /// <para>SEM_FAILCRITICALERRORS flagmustbe set before using LibVLC.</para>
 /// <para>On later versions, that is optional and unnecessary.</para>
 /// <para>Also on Microsoft Windows (Vista and any later version), setting the default</para>
 /// <para>DLL directories to SYSTEM32 exclusively is strongly recommended for</para>
 /// <para>security reasons:</para>
 /// <para>Arguments are meant to be passed from the command line to LibVLC, just like</para>
 /// <para>VLC media player does. The list of valid arguments depends on the LibVLC</para>
 /// <para>version, the operating system and platform, and set of available LibVLC</para>
 /// <para>plugins. Invalid or unsupported arguments will cause the function to fail</para>
 /// <para>(i.e. return NULL). Also, some arguments may alter the behaviour or</para>
 /// <para>otherwise interfere with other LibVLC functions.</para>
 /// <para>There is absolutely no warranty or promise of forward, backward and</para>
 /// <para>cross-platform compatibility with regards to libvlc_new() arguments.</para>
 /// <para>We recommend that you do not use them, other than when debugging.</para>
 /// </remarks>
 public LibVLC(string[] args = null)
     : base(() =>
 {
     var utf8Args = default(IntPtr[]);
     try
     {
         utf8Args = MarshalUtils.ToUtf8(args);
         return(Native.LibVLCNew(utf8Args.Length, utf8Args));
     }
     finally
     {
         foreach (var arg in utf8Args)
         {
             if (arg != IntPtr.Zero)
             {
                 Marshal.FreeHGlobal(arg);
             }
         }
     }
 }, Native.LibVLCRelease)
 {
     __ownsNativeInstance = true;
     NativeToManagedMap[NativeReference] = this;
 }