예제 #1
0
        public void Dispose()
        {
            if (_pointer == IntPtr.Zero) return;

            LibVlcManager.ReleaseTrackDescriptionList(_pointer);
            _pointer = IntPtr.Zero;
            _list.Clear();
        }
예제 #2
0
        public void Dispose()
        {
            if (_pointer == IntPtr.Zero)
            {
                return;
            }

            LibVlcManager.ReleaseAudioOutputList(_pointer);
            _pointer = IntPtr.Zero;
            _list.Clear();
        }
예제 #3
0
파일: VlcMedia.cs 프로젝트: forplus/Popcorn
        public MediaTrackInfo[] GetTrackInfo()
        {
            IntPtr pointer;
            var    count  = _getTracksInfoFunction.Delegate(InstancePointer, out pointer);
            var    result = new MediaTrackInfo[count];
            var    temp   = pointer;

            for (var i = 0; i < count; i++)
            {
                result[i] = (MediaTrackInfo)Marshal.PtrToStructure(temp, typeof(MediaTrackInfo));
                temp      = (IntPtr)((int)temp + Marshal.SizeOf(typeof(MediaTrackInfo)));
            }

            LibVlcManager.Free(pointer);
            return(result);
        }
예제 #4
0
        /// <summary>
        ///     Create a list of media track from a pointer of array.
        /// </summary>
        /// <param name="pointer">pointer of media track array</param>
        /// <param name="count">count of media track array</param>
        public MediaTrackList(IntPtr pointer, uint count)
        {
            _list = new List <MediaTrack>();

            if (pointer == IntPtr.Zero)
            {
                return;
            }

            var tmp = pointer;

            for (var i = 0; i < count; i++)
            {
                var p = Marshal.ReadIntPtr(tmp);
                _list.Add(MediaTrack.CreateFromPointer(p));
                tmp = (IntPtr)((Int64)tmp + IntPtr.Size);
            }

            LibVlcManager.ReleaseTracks(pointer, count);
        }
예제 #5
0
        /// <summary>
        ///     Convert a pointer of string to manmaged <see cref="String" />.
        /// </summary>
        /// <param name="ptr">pointer of string</param>
        /// <param name="count">count of string, -1 mean auto check the end char</param>
        /// <param name="toBeFree">free this pointer when convert over</param>
        /// <param name="encoding">encoding of string</param>
        /// <returns>result string</returns>
        public static String PtrToString(IntPtr ptr, int count = -1, bool toBeFree = false, Encoding encoding = null)
        {
            if (ptr == IntPtr.Zero)
            {
                return(null);
            }
            if (encoding == null)
            {
                encoding = Encoding.UTF8;
            }

            List <byte> buffer = new List <byte>(1024);

            if (count == -1)
            {
                int  offset = 0;
                byte tmp    = Marshal.ReadByte(ptr, offset);
                while (tmp != 0)
                {
                    buffer.Add(tmp);
                    offset++;
                    tmp = Marshal.ReadByte(ptr, offset);
                }
            }
            else
            {
                byte tmp = 0;
                for (int i = 0; i < count; i++)
                {
                    tmp = Marshal.ReadByte(ptr, i);
                    buffer.Add(tmp);
                }
            }

            if (toBeFree)
            {
                LibVlcManager.Free(ptr);
            }

            return(encoding.GetString(buffer.ToArray()));
        }