<div>Hello!</div><div> </div><div>I'm trying to properly release a part of my pipeline.</div><div> </div><div>This is my code for it:</div><div> </div><div> </div><div><div><div>static void dispose(std::shared_ptr<Pipeline> pipeline) {<!-- --></div><div>    gst_element_set_state(pipeline->audioconvert, GST_STATE_NULL);</div><div>    gst_element_set_state(pipeline->selector, GST_STATE_NULL);</div><div>    gst_element_set_state(pipeline->queue, GST_STATE_NULL);</div><div>    gst_element_set_state(pipeline->appsrc, GST_STATE_NULL);</div><div> </div><div>    gst_bin_remove(GST_BIN(mainPipeline), pipeline->appsrc);</div><div>    gst_bin_remove(GST_BIN(mainPipeline), pipeline->queue);</div><div>    gst_bin_remove(GST_BIN(mainPipeline), pipeline->selector);</div><div>    gst_bin_remove(GST_BIN(mainPipeline), pipeline->audioconvert);</div><div> </div><div>    gst_object_unref(pipeline->audioconvert);</div><div>    gst_object_unref(pipeline->selector);</div><div>    gst_object_unref(pipeline->queue);</div><div>    gst_object_unref(pipeline->appsrc);</div><div>}</div><div> </div><div> </div><div>When I do my gst_object_unref's, I get the following message for each of unref'd elements:</div><div> </div><div> </div><div>GStreamer-CRITICAL **: 11:48:02.088: gst_object_unref: assertion '((GObject *) object)->ref_count > 0' failed</div><div> </div><div> </div><div>Using gdb, I found out, that some of the refs are created by gst_element_set_state, following this trace: gst_element_set_state -> gst_element_set_state_func -> gst_element_change_state -> gst_element_continue_state -> _priv_gst_element_state_changed -> gst_message_new_state_changed -> gst_message_new_custom -> gst_message_init -> gst_object_ref</div><div> </div><div> </div><div>Looks like it's trying to send me a GST_ELEMENT_STATE_CHANGED message and takes a reference of my element for it. But I don't need that message, and even if I handle it, I still can't unref my element in the handler callback function, because the message and the element inside of it is unref'ed only after callback has finished.</div><div> </div><div>Can I properly unref my elements here, or maybe block GST_ELEMENT_STATE_CHANGED messages somehow?</div></div></div>