public void TestPipelineDispose() { Gst.Pipeline pipeline = new Gst.Pipeline(); var src = ElementFactory.Make("videotestsrc"); src["num-buffers"] = 10; var vsink = ElementFactory.Make("fakesink"); pipeline.Add(src, vsink); src.Link(vsink); var srcWeakRef = new WeakReference(src); var vsinkWeakRef = new WeakReference(vsink); var pipelineWeakRef = new WeakReference(pipeline); var busWeakRef = new WeakReference(pipeline.Bus); pipeline.SetState(State.Playing); bool terminated = false; do { using (Message msg = pipeline.Bus.PopFiltered(MessageType.StateChanged)) { if (msg == null || msg.Src != pipeline) { continue; } msg.ParseStateChanged(out State oldstate, out State newstate, out State pendingstate); if (newstate == State.Playing) { terminated = true; } } } while (!terminated); pipeline.SetState(State.Null); pipeline.Dispose(); pipeline = null; GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Assert.IsFalse(srcWeakRef.IsAlive); Assert.IsFalse(vsinkWeakRef.IsAlive); Assert.IsFalse(busWeakRef.IsAlive); Assert.IsFalse(pipelineWeakRef.IsAlive); }
public MainWindow() : base(WindowType.Toplevel) { BuildInterface (); pipeline = new Gst.Pipeline (); drawSink = Gst.ElementFactory.Make ("xvimagesink"); camerabin = Gst.ElementFactory.Make ("camerabin"); camerabin.Connect ("image-done", new Gst.SignalHandler (OnImageDone)); pipeline.SetState (Gst.State.Null); overlayAdapter = new Gst.Interfaces.XOverlayAdapter (drawSink.Handle); overlayAdapter.XwindowId = gdk_x11_drawable_get_xid (drawingArea.GdkWindow.Handle); pipeline.Add (camerabin); if (camerabin.HasProperty ("viewfinder-sink")) { camerabin ["viewfinder-sink"] = drawSink; } if (camerabin.HasProperty ("filename")) { camerabin ["filename"] = "snapshot.png"; } pipeline.SetState (Gst.State.Playing); this.ShowAll (); }