Gst_object_unref() gets stuck

I have several RTSP streams and APIs that manage my pipeline.
When I change the RTSP count, I recreate my pipeline. I remove the old pipeline in this way:

1 auto status = gst_element_set_state(m_pipeline, GST_STATE_NULL);
2 LOG_INFO("status is {}", status);
3 gst_object_unref(GST_OBJECT(m_pipeline));
4 g_source_remove(m_bus_watch_id);
5 g_main_loop_quit(m_loop);
6 g_main_loop_unref(m_loop);

Sometimes pipeline removal gets stuck on line 3 (gst_object_unref(GST_OBJECT(m_pipeline));). status is always 1.
what could be the problem?

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU)
• DeepStream Version
• JetPack Version (valid for Jetson only)
• TensorRT Version
• NVIDIA GPU Driver Version (valid for GPU only)
• Issue Type( questions, new requirements, bugs)
• How to reproduce the issue ? (This is for bugs. Including which sample app is using, the configuration files content, the command line used and other details for reproducing)
• Requirement details( This is for new requirement. Including the module name-for which plugin or for which sample application, the function description)

You must wait until the pipeline state is “NULL”. What are states? (

Hi @Fiona.Chen , thank you for reply!
After gst_element_set_state I added the following code

GstState state;
gst_element_get_state(pipeline, &state, 0, GST_CLOCK_TIME_NONE);

I always get state equal to 1 and the line gst_object_unref still gets stuck sometimes.

typedef enum {
  GST_STATE_NULL                = 1,
  GST_STATE_READY               = 2,
  GST_STATE_PAUSED              = 3,
  GST_STATE_PLAYING             = 4
} GstState;

Where did you do this? Another thread?

I did it in the same thread

1 gst_element_set_state(m_pipeline, GST_STATE_NULL);
2 GstState state;
3 gst_element_get_state(pipeline, &state, 0, GST_CLOCK_TIME_NONE);
4 g_print(state);
5 gst_object_unref(GST_OBJECT(m_pipeline));
6 g_source_remove(m_bus_watch_id);
7 g_main_loop_quit(m_loop);
8 g_main_loop_unref(m_loop);

The controlling should be in another thread. If you ant to control the pipeline, do not create and destroy the pipeline in the main thread. You need a pipeline thread and control the pipeline in another thread.

I’ve decided my problem by changed g_main_loop to endless loop while and sent eos message to pipeline.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.