NVorbis.OpenTKSupport.OggStream.Dispose C# (CSharp) Method

Dispose() public method

public Dispose ( ) : void
return void
        public void Dispose()
        {
            var state = AL.GetSourceState(alSourceId);
            if (state == ALSourceState.Playing || state == ALSourceState.Paused)
                StopPlayback();

            lock (prepareMutex)
            {
                OggStreamer.Instance.RemoveStream(this);

                if (state != ALSourceState.Initial)
                    Empty();

                Close();

                underlyingStream.Dispose();
            }

            AL.DeleteSource(alSourceId);
            AL.DeleteBuffers(alBufferIds);

            if (ALHelper.Efx.IsInitialized)
                ALHelper.Efx.DeleteFilter(alFilterId);

            ALHelper.Check();

            Logger.Log(LogEventSingle.MemoryUsage, () => GC.GetTotalMemory(true));
        }

Usage Example

Esempio n. 1
0
        internal Song(string name, string file, AudioFormat format = AudioFormat.Ogg)
        {
            if (format != AudioFormat.Ogg)
                throw new NotImplementedException("Support for formats other than ogg is not yet implemented.");

            _name = name;
            _file = file;

            try
            {
                _stream = new OggStream(_file);
                _stream.Prepare();
            }
            catch (InvalidDataException)
            {
                _stream.Dispose();
                _stream = new OggStream(_file);
                _stream.Prepare();
            }
        }