예제 #1
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);
        }