Exemplo n.º 1
0
        public override string ToString()
        {
            BufferStatus bufferStatus = new BufferStatus();

            this.UpdateBufferStatus(bufferStatus);
            return(string.Format("{0} count {1} size {2} newest {3} oldest {4}", (object)this.StreamType.Contents, (object)bufferStatus.PacketCount, (object)bufferStatus.Size, (object)bufferStatus.Newest, (object)bufferStatus.Oldest));
        }
Exemplo n.º 2
0
 public Number Read()
 {
     if (status != BufferStatus.AwaitingRead) {
         throw new InvalidOperationException("Buffer was not awaiting read.");
     }
     status = BufferStatus.AwaitingWrite;
     return bufferedValue;
 }
Exemplo n.º 3
0
 public void Write(Number value)
 {
     if (status != BufferStatus.AwaitingWrite) {
         throw new InvalidOperationException("Buffer was not awaiting write.");
     }
     bufferedValue = value;
     status = BufferStatus.AwaitingRead;
 }
Exemplo n.º 4
0
        public SecondaryBuffer GetBuffer(Sounds parent)
        {
            if (this.m_Empty)
            {
                return(null);
            }
            SecondaryBuffer buffer = null;

            for (int i = 0; i < this.m_Count; i++)
            {
                SecondaryBuffer buffer2 = (SecondaryBuffer)this.m_Buffers[i];
                BufferStatus    status  = buffer2.get_Status();
                if (!status.get_Playing() && !status.get_BufferLost())
                {
                    return(buffer2);
                }
                if (status.get_BufferLost())
                {
                    this.m_Buffers.RemoveAt(i);
                    i--;
                    this.m_Count--;
                }
                else
                {
                    buffer = buffer2;
                }
            }
            if (buffer != null)
            {
                try
                {
                    SecondaryBuffer buffer3 = buffer.Clone(parent.Device);
                    if (buffer3 != null)
                    {
                        this.m_Buffers.Add(buffer3);
                        this.m_Count++;
                        return(buffer3);
                    }
                }
                catch (Exception exception)
                {
                    Debug.Error(exception);
                }
            }
            SecondaryBuffer buffer4 = parent.ReadFromDisk(this.m_SoundID);

            if (buffer4 != null)
            {
                this.m_Buffers.Add(buffer4);
                this.m_Count++;
            }
            else
            {
                this.m_Empty = true;
            }
            return(buffer4);
        }
Exemplo n.º 5
0
 private SecondarySoundBuffer FindAvailableBuffer()
 {
     for (int index = 0; index < this._buffers.Count; ++index)
     {
         SecondarySoundBuffer secondarySoundBuffer = this._buffers[index];
         BufferStatus         bufferStatus         = (BufferStatus)((SoundBuffer)secondarySoundBuffer).Status;
         if (((Enum)(object)bufferStatus).HasFlag((Enum)(object)(BufferStatus)2))
         {
             this._buffers.RemoveAt(index--);
             ((DisposeBase)secondarySoundBuffer).Dispose();
         }
         else if (!((Enum)(object)bufferStatus).HasFlag((Enum)(object)(BufferStatus)1))
         {
             return(secondarySoundBuffer);
         }
     }
     return((SecondarySoundBuffer)null);
 }
Exemplo n.º 6
0
        public void UpdateBufferStatus(BufferStatus bufferStatus)
        {
            bool   lockTaken = false;
            object obj       = null;

            try
            {
                Monitor.Enter(obj        = this._packetsLock, ref lockTaken);
                bufferStatus.PacketCount = this._packets.Count;
                bufferStatus.Size        = this._size;
                bufferStatus.Newest      = this._newest;
                bufferStatus.Oldest      = this._oldest;
                bufferStatus.IsValid     = this._packets.Count > 0 && this._newest.HasValue && this._oldest.HasValue;
                bufferStatus.IsDone      = this._isDone;
                bufferStatus.IsMedia     = this._isMedia;
            }
            finally
            {
                if (lockTaken)
                {
                    Monitor.Exit(obj);
                }
            }
        }
Exemplo n.º 7
0
 internal LargBuffer(byte[] buffer, int id, BufferStatus status) : this(buffer, id)
 {
     _status = status;
 }
Exemplo n.º 8
0
 public BufferRW()
 {
     status = BufferStatus.AwaitingWrite;
 }
Exemplo n.º 9
0
        public override string ToString()
        {
            var bufferStatus = new BufferStatus();

            UpdateBufferStatus(bufferStatus);

            return string.Format("{0} count {1} size {2} newest {3} oldest {4}",
                StreamType.Contents, bufferStatus.PacketCount, bufferStatus.Size, bufferStatus.Newest, bufferStatus.Oldest);
        }
Exemplo n.º 10
0
 public void UpdateBufferStatus(BufferStatus bufferStatus)
 {
     lock (_packetsLock)
     {
         bufferStatus.PacketCount = _packets.Count;
         bufferStatus.Size = _size;
         bufferStatus.Newest = _newest;
         bufferStatus.Oldest = _oldest;
         bufferStatus.IsValid = _packets.Count > 0 && _newest.HasValue && _oldest.HasValue;
         bufferStatus.IsDone = _isDone;
         bufferStatus.IsMedia = _isMedia;
     }
 }
Exemplo n.º 11
0
 internal LargBuffer(byte[] buffer,int id, BufferStatus status):this(buffer,id)
 {
     _status = status;
 }
 /// <summary>
 /// Sets the type of buffer for write operations.
 /// </summary>
 /// <param name="type">The type of buffer being written.</param>
 /// <param name="status">The default status of the buffer.</param>
 public void SetBufferType(BufferType type, BufferStatus status)
 {
     _writeBufferType   = type;
     _writeBufferStatus = status;
 }