Exemple #1
0
        private void EnsureOutputData()
        {
            while (mDecoder.AvailableOutputLength == 0 && !mDecoder.IsOutputComplete)
            {
                if (mOffset == mEnding)
                {
                    mOffset = 0;
                    mEnding = 0;

                    var fetched = mInput.Read(mBuffer, 0, mBuffer.Length);
                    System.Diagnostics.Debug.Assert(0 <= fetched && fetched <= mBuffer.Length);

                    if (fetched == 0)
                    {
                        mDecoder.Decode(null, 0, 0, null, true);
                        System.Diagnostics.Debug.Assert(mDecoder.AvailableOutputLength > 0 || mDecoder.IsOutputComplete);
                        continue;
                    }

                    mEnding = fetched;
                }

                var written = mDecoder.Decode(mBuffer, mOffset, mEnding - mOffset, (int)Math.Min(Int32.MaxValue, mLength - mPosition), false);
                System.Diagnostics.Debug.Assert(0 <= written && written <= mEnding - mOffset);
                mOffset += written;
            }
        }