rpicamsrc: RaspiCapture: use mmal_queue_timedwait() for buffer queueing
authorGeorgii Staroselskii <georgii.staroselskii@emlid.com>
Wed, 8 Nov 2017 09:14:35 +0000 (09:14 +0000)
committerTim-Philipp Müller <tim@centricular.com>
Fri, 10 Jul 2020 15:46:15 +0000 (16:46 +0100)
If an external camera was disconnected, there were no feedback in an
application. It seems reasonable to wait on mmal_queue no longer than
100ms. If it's stuck we just return a FLOW_ERROR and let the application
decide what to do later.

sys/rpicamsrc/RaspiCapture.c

index cdc6ce2..1d899cf 100644 (file)
@@ -938,8 +938,12 @@ raspi_capture_fill_buffer(RASPIVID_STATE *state, GstBuffer **bufp,
   GstClockTime gst_pts = GST_CLOCK_TIME_NONE;
 
   /* FIXME: Use our own interruptible cond wait: */
-  buffer = mmal_queue_wait(state->encoded_buffer_q);
 
+  buffer = mmal_queue_timedwait(state->encoded_buffer_q, 100);
+
+  if (G_UNLIKELY(buffer == NULL)) {
+      return GST_FLOW_ERROR;
+  }
 
   if (G_LIKELY (config->useSTC && clock)) {
     MMAL_PARAMETER_INT64_T param;