示例#1
0
        protected internal override void OnFillBuffer(FillBufferEventArgs e)
        {
            base.OnFillBuffer(e);

            if (spareBuffer == null || spareBuffer.Length < e.Buffer.Length)
            {
                spareBuffer = new Sample[e.Buffer.Length];
            }

            bool needToRemove = false;

            foreach (var playing in nowPlaying)
            {
                playing.wavefile.GetSampleData(playing.through, spareBuffer, 0, e.Buffer.Length);
                playing.through += e.Buffer.Length;

                if (playing.through >= playing.wavefile.NumberOfSamples)
                {
                    needToRemove = true;
                }

                for (int i = 0; i < e.Buffer.Length; i++)
                {
                    e.Buffer[i] += spareBuffer[i];
                }
            }

            if (needToRemove)
            {
                lock (nowPlaying)
                {
                    //nowPlaying.RemoveAll(p => p.through >= p.wavefile.NumberOfSamples);
                    nowPlaying = SimpleLinkedList <NowPlaying> .CreateReversed(
                        nowPlaying.Where(p => p.through < p.wavefile.NumberOfSamples));
                }
            }

            //for (int i=0; i<
        }