> > + gst_object_ref(vs->h264->source); > > + if (!gst_bin_add(GST_BIN(vs->h264->pipeline), vs->h264->source)) { > > + gst_object_unref(vs->h264->source); > > + VNC_DEBUG("Could not add source to gst pipeline\n"); > > + goto error; > > + } > > If you put the gst_object_ref call after sucessfully calling > gst_bin_add, then it wouldn't need the gst_object_unref call > on failure. Repeated many times below.
Gstreamer docs claims that gst_bin_add() takes ownership of the element. So I assumed that it unref the element in case of error. If I do not ref the object before, this would free the object too early. But a look at the source code of gstbin.c reveals that it does not unref the element in case of errors, so your suggestion works. I will change that in the next version... - Dietmar