imagefreeze: Wait until we have a clock
authorVivia Nikolaidou <vivia@ahiru.eu>
Tue, 4 Aug 2020 12:49:43 +0000 (15:49 +0300)
committerVivia Nikolaidou <vivia@ahiru.eu>
Tue, 4 Aug 2020 14:28:39 +0000 (17:28 +0300)
Otherwise it can happen that it tries to get the clock in PAUSED state
in live mode, which does not exist.

Thanks to Sebastian Dröge for helping debugging.

Fixes #775

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/merge_requests/691>

gst/imagefreeze/gstimagefreeze.c

index 7a287a6..9e50bc6 100644 (file)
@@ -962,19 +962,24 @@ gst_image_freeze_src_loop (GstPad * pad)
     GstClockReturn clock_ret;
     GstClock *clock;
 
+    clock = gst_element_get_clock (GST_ELEMENT (self));
+
     /* Wait until the element went to PLAYING or flushing */
-    while (self->blocked && !self->flushing)
+    while ((!clock || self->blocked) && !self->flushing) {
       g_cond_wait (&self->blocked_cond, &self->lock);
+      gst_clear_object (&clock);
+      clock = gst_element_get_clock (GST_ELEMENT (self));
+    }
 
     if (self->flushing) {
       g_mutex_unlock (&self->lock);
       gst_buffer_unref (buffer);
       flow_ret = GST_FLOW_FLUSHING;
+      gst_clear_object (&clock);
       goto pause_task;
     }
 
     /* Wait on the clock until the time for our current frame is reached */
-    clock = gst_element_get_clock (GST_ELEMENT (self));
     base_time = gst_element_get_base_time (GST_ELEMENT (self));
     if (self->fps_n != 0) {
       clock_time =