Esempio n. 1
0
        /// <summary>
        /// Disposes this instance.
        /// </summary>
        public virtual void Dispose()
        {
            if (_graphBuilder == null)
            {
                return;
            }
            Log.Log.WriteFile("analog:Dispose()");
            if (!CheckThreadId())
            {
                return;
            }

            if (_graphState == GraphState.TimeShifting || _graphState == GraphState.Recording)
            {
                // Stop the graph first. To ensure that the timeshift files are no longer blocked
                StopGraph();
            }
            FreeAllSubChannels();
            IMediaControl mediaCtl = (_graphBuilder as IMediaControl);

            if (mediaCtl == null)
            {
                throw new TvException("Can not convert graphBuilder to IMediaControl");
            }
            // Decompose the graph
            mediaCtl.Stop();
            FilterGraphTools.RemoveAllFilters(_graphBuilder);
            Log.Log.WriteFile("analog:All filters removed");
            if (_tuner != null)
            {
                _tuner.Dispose();
                _tuner       = null;
                _tunerDevice = null;
            }
            if (_crossbar != null)
            {
                _crossbar.Dispose();
                _crossbar = null;
            }
            if (_tvAudio != null)
            {
                _tvAudio.Dispose();
                _tvAudio = null;
            }
            if (_capture != null)
            {
                _capture.Dispose();
                _capture = null;
            }
            if (_encoder != null)
            {
                _encoder.Dispose();
                _encoder = null;
            }
            if (_teletext != null)
            {
                _teletext.Dispose();
                _teletext = null;
            }
            if (_tsFileSink != null)
            {
                Release.ComObject("tsFileSink filter", _tsFileSink);
                _tsFileSink = null;
            }
            _rotEntry.Dispose();
            _rotEntry = null;
            Release.ComObject("Graphbuilder", _graphBuilder);
            _graphBuilder = null;
            _graphState   = GraphState.Idle;
            Log.Log.WriteFile("analog: dispose completed");
        }