Пример #1
0
            unsafe bool IEnumerator.MoveNext()
            {
                SL3Reader src = source;

                if (src.Read(new(pCurrent, Frame.Size)) != Frame.Size)
                {
                    return(false); // Unable to read. It could be due to EOF or IO error.
                }
                return(src.Seek(pCurrent->TotalLength - Frame.Size, SeekOrigin.Current) < fileLength);
                // Avoid returning non-complete frame.
            }
Пример #2
0
            public unsafe Enumerator(SL3Reader source)
            {
                bool lockTaken = false;

                Monitor.Enter(source, ref lockTaken);
                if (!lockTaken)
                {
                    throw new IOException("Unable to lock stream for single access use.");
                }

                aCurrent    = GC.AllocateArray <Frame>(1, true);
                pCurrent    = (Frame *)Unsafe.AsPointer(ref aCurrent[0]);
                this.source = source;
                fileLength  = source.Length;
                ((IEnumerator)this).Reset();
            }