summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2018-09-12 05:29:09 -0500
committerMatthew Waters <matthew@centricular.com>2018-09-12 21:17:13 +1000
commit946cbbccc15f707857a550065fa7ba0028e4d627 (patch)
treee134785580b0dc26370870b097acb6eb1f1c5145
parentbf849e9a69442f7a6f9d4f0a1ef30d5a8009f689 (diff)
decklink: wait for stop with a timeout
Decklink sometimes does not notify us through the callback that it has stopped scheduled playback either because it was uncleanly shutdown without an explicit stop or for unknown other reasons. Wait on the cond for a short amount of time before checking if scheduled playback has stopped without notification. https://bugzilla.gnome.org/show_bug.cgi?id=797130
-rw-r--r--sys/decklink/gstdecklinkvideosink.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/sys/decklink/gstdecklinkvideosink.cpp b/sys/decklink/gstdecklinkvideosink.cpp
index 7f362f508..8a9f4bcf0 100644
--- a/sys/decklink/gstdecklinkvideosink.cpp
+++ b/sys/decklink/gstdecklinkvideosink.cpp
@@ -853,6 +853,21 @@ gst_decklink_video_sink_stop (GstDecklinkVideoSink * self)
}
static void
+_wait_for_stop_notify (GstDecklinkVideoSink *self)
+{
+ bool active = false;
+
+ self->output->output->IsScheduledPlaybackRunning (&active);
+ while (active) {
+ /* cause sometimes decklink stops without notifying us... */
+ guint64 wait_time = g_get_monotonic_time () + G_TIME_SPAN_SECOND;
+ if (!g_cond_wait_until (&self->output->cond, &self->output->lock, wait_time))
+ GST_WARNING_OBJECT (self, "Failed to wait for stop notification");
+ self->output->output->IsScheduledPlaybackRunning (&active);
+ }
+}
+
+static void
gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
{
GstDecklinkVideoSink *self = GST_DECKLINK_VIDEO_SINK_CAST (element);
@@ -923,10 +938,7 @@ gst_decklink_video_sink_start_scheduled_playback (GstElement * element)
return;
}
// Wait until scheduled playback actually stopped
- do {
- g_cond_wait (&self->output->cond, &self->output->lock);
- self->output->output->IsScheduledPlaybackRunning (&active);
- } while (active);
+ _wait_for_stop_notify (self);
}
GST_DEBUG_OBJECT (self,
@@ -986,13 +998,9 @@ gst_decklink_video_sink_stop_scheduled_playback (GstDecklinkVideoSink * self)
res));
ret = GST_STATE_CHANGE_FAILURE;
} else {
- bool active = false;
// Wait until scheduled playback actually stopped
- do {
- g_cond_wait (&self->output->cond, &self->output->lock);
- self->output->output->IsScheduledPlaybackRunning (&active);
- } while (active);
+ _wait_for_stop_notify (self);
}
if (start_time > 0)
self->scheduled_stop_time = start_time;