Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of <see cref="VorbisReader"/> reading from the specified stream, optionally taking ownership of it.
        /// </summary>
        /// <param name="stream">The <see cref="Stream"/> to read from.</param>
        /// <param name="closeOnDispose"><see langword="true"/> to take ownership and clean up the instance when disposed, otherwise <see langword="false"/>.</param>
        public VorbisReader(Stream stream, bool closeOnDispose = true)
        {
            _decoders = new List <IStreamDecoder>();

            var containerReader = CreateContainerReader(stream, closeOnDispose);

            containerReader.NewStreamCallback = ProcessNewStream;

            if (!containerReader.TryInit() || _decoders.Count == 0)
            {
                containerReader.NewStreamCallback = null;
                containerReader.Dispose();

                if (closeOnDispose)
                {
                    stream.Dispose();
                }

                throw new ArgumentException("Could not load the specified container!", nameof(containerReader));
            }
            _closeOnDispose  = closeOnDispose;
            _containerReader = containerReader;
            _streamDecoder   = _decoders[0];
        }
Esempio n. 2
0
 public VorbisReader(Contracts.IContainerReader containerReader) => throw new NotSupportedException();