Example #1
0
        static void OnLogInternal(IntPtr data, LogLevel level, IntPtr ctx, IntPtr format, IntPtr args)
        {
            if (data == IntPtr.Zero)
            {
                return;
            }

            var gch = GCHandle.FromIntPtr(data);

            if (!gch.IsAllocated || !(gch.Target is LibVLC libvlc) || libvlc.IsDisposed)
            {
                return;
            }

            try
            {
                var message = MarshalUtils.GetLogMessage(format, args);

                GetLogContext(ctx, out var module, out var file, out var line);
#if NET40
                Task.Factory.StartNew(() => libvlc._log?.Invoke(null, new LogEventArgs(level, message, module, file, line)));
#else
                Task.Run(() => libvlc._log?.Invoke(null, new LogEventArgs(level, message, module, file, line)));
#endif
            }
            // Silently catching OOM exceptions and others as this is not critical if it fails
            catch
            {
            }
        }