/// <summary>
 /// Disposes the <see cref="WriteableBufferingSource"/> and its internal buffer.
 /// </summary>
 /// <param name="disposing">True to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
 protected virtual void Dispose(bool disposing)
 {
     if (disposing)
     {
         //dispose managed
         _buffer.Dispose();
         _buffer = null;
     }
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="WriteableBufferingSource"/> class.
        /// </summary>
        /// <param name="waveFormat">The WaveFormat of the source.</param>
        /// <param name="bufferSize">Buffersize in bytes.</param>
        public MyWriteableBufferingSource(WaveFormat waveFormat, int bufferSize)
        {
            if (waveFormat == null)
            {
                throw new ArgumentNullException("waveFormat");
            }
            if (bufferSize <= 0 || (bufferSize % waveFormat.BlockAlign) != 0)
            {
                throw new ArgumentException("Invalid bufferSize.");
            }

            MaxBufferSize = bufferSize;

            _waveFormat   = waveFormat;
            _buffer       = new MyFixedSizeBuffer <byte>(bufferSize);
            FillWithZeros = true;
        }