protected override void DoStopInternal(object state) { IFilterGraph graph = mediaControl as IFilterGraph; if (graph != null) { if (mediaControl != null) { int hr = mediaControl.Stop(); DsError.ThrowExceptionForHR(hr); mediaControl = null; } IEnumFilters pEnum = null; if (COMHelper.SUCCEEDED(graph.EnumFilters(out pEnum)) && pEnum != null) { List <IBaseFilter> allFilters = new List <IBaseFilter>(); IBaseFilter[] aFilters = new IBaseFilter[1]; while (COMHelper.S_OK == pEnum.Next(1, aFilters, IntPtr.Zero)) { allFilters.Add(aFilters[0]); } Marshal.ReleaseComObject(pEnum); foreach (var f in allFilters) { if (f != null) { graph.RemoveFilter(f); } } } } base.DoStopInternal(state); }