From f98bb0642ef7ef30ef07af42a9b6ab5c84cfe79e Mon Sep 17 00:00:00 2001 From: tinyzimmer <38474291+tinyzimmer@users.noreply.github.com> Date: Sat, 3 Oct 2020 16:09:25 +0300 Subject: [PATCH] add more comments to appsink example --- examples/appsink/main.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/appsink/main.go b/examples/appsink/main.go index 103802b..1e1a722 100644 --- a/examples/appsink/main.go +++ b/examples/appsink/main.go @@ -82,12 +82,16 @@ func createPipeline() (*gst.Pipeline, error) { } func mainLoop(pipeline *gst.Pipeline) error { - defer pipeline.Destroy() + defer pipeline.Destroy() // Will stop and unref the pipeline when this function returns + + // Start the pipeline pipeline.SetState(gst.StatePlaying) + // Retrieve the bus from the pipeline bus := pipeline.GetPipelineBus() + // Loop over messsages from the pipeline for { msg := bus.TimedPop(time.Duration(-1)) if msg == nil { @@ -95,10 +99,14 @@ func mainLoop(pipeline *gst.Pipeline) error { } switch msg.Type() { case gst.MessageEOS: + msg.Unref() // Messsages are a good candidate for trying out runtime finalizers break case gst.MessageError: - return msg.ParseError() + err := msg.ParseError() + msg.Unref() + return err } + msg.Unref() } return nil