static void dispose(std::shared_ptr<Pipeline> pipeline) {
gst_element_set_state(pipeline->audioconvert, GST_STATE_NULL);
gst_element_set_state(pipeline->selector, GST_STATE_NULL);
gst_element_set_state(pipeline->queue, GST_STATE_NULL);
gst_element_set_state(pipeline->appsrc, GST_STATE_NULL);
gst_bin_remove(GST_BIN(mainPipeline), pipeline->appsrc);
gst_bin_remove(GST_BIN(mainPipeline), pipeline->queue);
gst_bin_remove(GST_BIN(mainPipeline), pipeline->selector);
gst_bin_remove(GST_BIN(mainPipeline), pipeline->audioconvert);
gst_object_unref(pipeline->audioconvert);
gst_object_unref(pipeline->selector);
gst_object_unref(pipeline->queue);
gst_object_unref(pipeline->appsrc);
}
When I do my gst_object_unref's, I get the following message for each of unref'd elements:
GStreamer-CRITICAL **: 11:48:02.088: gst_object_unref: assertion '((GObject *) object)->ref_count > 0' failed
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
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.
Can I properly unref my elements here, or maybe block GST_ELEMENT_STATE_CHANGED messages somehow?