Beispiel #1
0
        private void Shutdown()
        {
            int hr = 0;

            // Remove the ROT entry
            if (rot != null)
            {
                rot.Dispose();
            }

            if (graphBuilder != null)
            {
                // Stop DirectShow notifications
                hr = (graphBuilder as IMediaEventEx).SetNotifyWindow(IntPtr.Zero, 0, IntPtr.Zero);

                // Stop the graph
                hr = (graphBuilder as IMediaControl).StopWhenReady();
                hr = (graphBuilder as IMediaControl).Stop();

                // Dispose the allocator
                allocator.Dispose();

                // Release DirectShow objects
                Marshal.ReleaseComObject(vmr9);
                Marshal.ReleaseComObject(graphBuilder);
                graphBuilder = null;

                FreeResources();

                // Free the Managed Direct3D device
                device.Dispose();
            }
        }
Beispiel #2
0
        private void CloseGraph()
        {
            FilterState state;

            if (mediaControl != null)
            {
                do
                {
                    mediaControl.Stop();
                    mediaControl.GetState(0, out state);
                } while (state != FilterState.Stopped);

                mediaControl = null;
            }

            if (allocator != null)
            {
                allocator.Dispose();
                allocator = null;
            }

            if (filter != null)
            {
                Marshal.ReleaseComObject(filter);
                filter = null;
            }


            if (graph != null)
            {
                RemoveAllFilters();

                Marshal.ReleaseComObject(graph);
                graph = null;
            }
        }