public void TestPipelineDispose() { Gst.Pipeline pipeline = new Gst.Pipeline(); var src = Gst.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 static void StopRecording() { if (gstRecording != null) { gstRecording.SetState(Gst.State.Null); Gst.State s; gstRecording.GetState(out s, timeout); gstRecording.Dispose(); gstRecording = null; } isRecording = false; }