mjhowell / gst-zeromq

GStreamer source and sink elements using ZeroMQ sockets
GNU General Public License v2.0
22 stars 20 forks source link

Trying to stop the pipeline whilst the src is awaiting data results in a hang #5

Open mangodan2003 opened 1 year ago

mangodan2003 commented 1 year ago

Blocked by

https://github.com/mjhowell/gst-zeromq/blob/master/src/zeromq/gstzmqsrc.c#L187

mjhowell commented 1 year ago

Hi @mangodan2003, I haven't touched this in a long time so it is not fresh in my mind. The code you highlight doesn't seem to have a nice way to be interrupted, so perhaps would be better calling zmq_msg_recv() with a timeout, or using zmq_poll().

Can you give a concrete example that I can use to reproduce your problem? gst-launch-1.0 command lines, etc.

Frenzie commented 1 month ago

A simple gst-launch like this will suffice:

gst-launch-1.0 -v zmqsrc endpoint=ipc:///tmp/bla-src ! fakesink dump=1

Compare the behavior when pressing Ctrl+C with udpsrc for example. udpsrc is immediate, zmqsrc takes a very long time.

Something along these lines does better in that test case but unfortunately not in a less artificial scenario.

-    rc = zmq_msg_recv (&msg, src->socket, 0);
+    rc = zmq_msg_recv (&msg, src->socket, ZMQ_DONTWAIT);
     if ((rc < 0) && (EAGAIN == errno)) {
       GST_LOG_OBJECT (src, "No message available on socket, errno: %d", errno);
+      g_main_context_iteration (NULL, FALSE);
+      g_usleep (1000);  // sleep for 1 millisecond
       continue;