예제 #1
0
        private void StartCopy(bool retry)
        {
            buffer = new byte[bufferSize];
            try
            {
                source.BeginRead(buffer, 0, buffer.Length, MediaReadAsyncCallback, new object());
            }
            catch (NotSupportedException e)
            {
                // we only diagnose problems with TsBuffer, other streams are supposed to work correctly
                if (!(source is TsBuffer))
                {
                    throw;
                }

                // TODO: is this still needed or are the TsBuffer problems solved?
                TsBuffer stream = (TsBuffer)source;
                Log.Error(string.Format("StreamCopy {0}: NotSupportedException when trying to read from TsBuffer", log), e);
                Log.Debug("StreamCopy {0}: TsBuffer dump: CanRead {1}, CanWrite {2}", log, stream.CanRead, stream.CanWrite);
                Log.Debug("StreamCopy {0}:\r\n{1}", log, stream.DumpStatus());
                if (retry)
                {
                    Thread.Sleep(500);
                    Log.Info("StreamCopy {0}: Trying to recover", log);
                    StartCopy(false);
                }
            }
        }
예제 #2
0
        private void CopyStream(bool retry)
        {
            // do a parallel read
            buffer = new byte[bufferSize];
            try
            {
                source.BeginRead(buffer, 0, buffer.Length, MediaReadAsyncCallback, new object());
            }
            catch (NotSupportedException e)
            {
                // we only do a workaround for TsBuffer here, nothing for other errors
                if (!(source is TsBuffer))
                {
                    throw;
                }

                TsBuffer stream = (TsBuffer)source;
                Log.Error(string.Format("StreamCopy {0}: NotSupportedException when trying to read from TsBuffer", log), e);
                Log.Info("StreamCopy {0}: TsBuffer dump: CanRead {1}, CanWrite {2}", log, stream.CanRead, stream.CanWrite);
                Log.Info("StreamCopy {0}:\r\n{1}", log, stream.DumpStatus());
                if (retry)
                {
                    Thread.Sleep(500);
                    Log.Info("StreamCopy {0}: Trying to recover", log);
                    CopyStream(false);
                }
            }
        }