I found a deadlock when I try to dynamically remove a stream after it has completed. In the deepstream-nvof-test app in Deepstream SDK 4.0, I modified the bus_call’s GST_MESSAGE_ELEMENT handling as follows:
case GST_MESSAGE_ELEMENT:
{
if (gst_nvmessage_is_stream_eos (msg)) {
guint stream_id;
if (gst_nvmessage_parse_stream_eos (msg, &stream_id)) {
g_print ("Got EOS from stream %d\n", stream_id);
GstElement *uri_decode_bin = gst_bin_get_by_name(GST_BIN(pipeline), "uri-decode-bin");
gst_element_set_state (uri_decode_bin, GST_STATE_NULL);
GstElement *streammux = gst_bin_get_by_name(GST_BIN(pipeline), "stream-muxer");
gchar pad_name[16] = { };
g_snprintf (pad_name, 15, "sink_%u", stream_id);
GstPad *sinkpad;
sinkpad = gst_element_get_static_pad (streammux, pad_name);
if (!sinkpad) {
g_printerr ("Streammux request sink pad failed. Exiting.\n");
return -1;
}
g_print ("Before release\n");
gst_element_release_request_pad (streammux, sinkpad);
g_print ("After release\n");
}
}
break;
}
The pipeline element pointer will need to be moved to the global scope at the top of the file to get this to compile. I’m running the program with one input. “Before release” is printed, but “After release” is not. When I do a stack trace I get:
#0 0x00007f5db2cf3839 in syscall () at /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007f5db35fd77f in g_cond_wait () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#2 0x00007f5db1d24ed0 in gst_nvstreammux_release_pad () at /usr/lib/x86_64-linux-gnu/gstreamer-1.0/deepstream/libnvdsgst_multistream.so
#3 0x000056198d2cfbba in bus_call ()
#4 0x00007f5db3b1acbd in () at /usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so.0
#5 0x00007f5db35b7285 in g_main_context_dispatch () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#6 0x00007f5db35b7650 in () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#7 0x00007f5db35b7962 in g_main_loop_run () at /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0
#8 0x000056198d2d0652 in main ()
Clearly, this thread is stuck waiting for a condition variable inside of gst_nvstreammux_release_pad. Any ideas on this? Are there any ways to work around it?
I tried pausing both the streammux as well as the whole pipeline before releasing the pad, but that didn’t help either.