CodeTV.GraphBuilderWDM.Decompose C# (CSharp) Method

Decompose() protected method

protected Decompose ( ) : void
return void
        protected override void Decompose()
        {
            if (this.graphBuilder != null)
            {
                int hr = 0;

                OnGraphEnded();

                // Decompose the graph
                try { hr = (this.graphBuilder as IMediaControl).StopWhenReady(); }
                catch { }
                try { hr = (this.graphBuilder as IMediaControl).Stop(); }
                catch { }
                RemoveHandlers();

                FilterGraphTools.RemoveAllFilters(this.graphBuilder);

                if (this.crossbarHelper != null) this.crossbarHelper.Dispose(); this.crossbarHelper = null;
                if (this.tuner != null) Marshal.ReleaseComObject(this.tuner); this.tuner = null;
                if (this.amTVAudio != null) Marshal.ReleaseComObject(this.amTVAudio); this.amTVAudio = null;
                if (this.crossbar != null) Marshal.ReleaseComObject(this.crossbar); this.crossbar = null;
                if (this.videoCaptureFilter != null) Marshal.ReleaseComObject(this.videoCaptureFilter); this.videoCaptureFilter = null;
                if (this.audioCaptureFilter != null) Marshal.ReleaseComObject(this.audioCaptureFilter); this.audioCaptureFilter = null;
                if (this.audioRenderer != null) Marshal.ReleaseComObject(this.audioRenderer); this.audioRenderer = null;
                if (this.videoRenderer != null) Marshal.ReleaseComObject(this.videoRenderer); this.videoRenderer = null;
                if (this.captureGraphBuilder != null) Marshal.ReleaseComObject(this.captureGraphBuilder); this.captureGraphBuilder = null;

                if (useWPF)
                    WPFStop();

                try { rot.Dispose(); }
                catch { }
                try { Marshal.ReleaseComObject(this.graphBuilder); this.graphBuilder = null; }
                catch { }
            }
        }