Commit b26ac27e authored by Martin Finkel's avatar Martin Finkel

removed unused stuff and add proper comments

parent 3c3d7b62
......@@ -43,6 +43,26 @@ namespace LibVLCSharp.Shared.Helpers
const string Write = "w";
}
internal static IntPtr CreateWithOptions(string[] options, Func<int, IntPtr[], IntPtr> create)
{
var utf8Args = default(IntPtr[]);
try
{
utf8Args = ToUtf8(options);
return create(utf8Args.Length, utf8Args);
}
finally
{
foreach (var arg in utf8Args)
{
if (arg != IntPtr.Zero)
{
Marshal.FreeHGlobal(arg);
}
}
}
}
internal static TU[] Retrieve<T, TU>(Func<IntPtr> getRef, Func<IntPtr, T> retrieve,
Func<T, TU> create, Func<T, IntPtr> next, Action<IntPtr> releaseRef)
where T : struct
......
......@@ -166,21 +166,11 @@ namespace LibVLCSharp.Shared
string format,
IntPtr args);
}
internal static readonly System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LibVLC> NativeToManagedMap
= new System.Collections.Concurrent.ConcurrentDictionary<IntPtr, LibVLC>();
protected bool __ownsNativeInstance;
/// <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>
......@@ -213,31 +203,12 @@ namespace LibVLCSharp.Shared
/// <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(params string[] args)
: 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)
/// </summary>
/// <param name="options">list of arguments (should be NULL)</param>
/// <returns>the libvlc instance or NULL in case of error</returns>
public LibVLC(params string[] options)
: base(() => MarshalUtils.CreateWithOptions(options, Native.LibVLCNew), Native.LibVLCRelease)
{
__ownsNativeInstance = true;
NativeToManagedMap[NativeReference] = this;
}
protected override void Dispose(bool disposing)
......@@ -264,11 +235,11 @@ namespace LibVLCSharp.Shared
return obj1?.NativeReference != obj2?.NativeReference;
}
/**
* Try to start a user interface for the libvlc instance.
*
* \param name interface name, or empty string for default
*/
/// <summary>
/// Try to start a user interface for the libvlc instance.
/// </summary>
/// <param name="name">interface name, or empty string for default</param>
/// <returns></returns>
public bool AddInterface(string name)
{
return Native.LibVLCAddInterface(NativeReference, name ?? string.Empty) == 0;
......
......@@ -1338,7 +1338,7 @@ namespace LibVLCSharp.Shared
/// <summary>
/// Set Spu (subtitle)
/// </summary>
/// <param name="spu">ideo subtitle track to select (id from track description)</param>
/// <param name="spu">Video subtitle track to select (id from track description)</param>
/// <returns>true on success, false otherwise</returns>
public bool SetSpu(int spu) => Native.LibVLCVideoSetSpu(NativeReference, spu) == 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment