mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
decklink: Add a clock epoch that is used as offset whenever restarting the clock
Otherwise we're going to return times starting at 0 again after shutting down an element for a specific input/output and then using it again later. https://bugzilla.gnome.org/show_bug.cgi?id=755426
This commit is contained in:
parent
e0fd5317df
commit
9764e22a5c
4 changed files with 10 additions and 2 deletions
|
@ -885,6 +885,7 @@ gst_decklink_clock_get_internal_time (GstClock * clock)
|
|||
|
||||
self->input->clock_last_time = result;
|
||||
}
|
||||
result += self->input->clock_epoch;
|
||||
g_mutex_unlock (&self->input->lock);
|
||||
} else if (self->output != NULL) {
|
||||
g_mutex_lock (&self->output->lock);
|
||||
|
@ -924,6 +925,7 @@ gst_decklink_clock_get_internal_time (GstClock * clock)
|
|||
|
||||
self->output->clock_last_time = result;
|
||||
}
|
||||
result += self->output->clock_epoch;
|
||||
g_mutex_unlock (&self->output->lock);
|
||||
} else {
|
||||
g_assert_not_reached ();
|
||||
|
|
|
@ -134,7 +134,7 @@ struct _GstDecklinkOutput {
|
|||
IDeckLink *device;
|
||||
IDeckLinkOutput *output;
|
||||
GstClock *clock;
|
||||
GstClockTime clock_start_time, clock_last_time;
|
||||
GstClockTime clock_start_time, clock_last_time, clock_epoch;
|
||||
GstClockTimeDiff clock_offset;
|
||||
gboolean started, clock_restart;
|
||||
|
||||
|
@ -162,7 +162,7 @@ struct _GstDecklinkInput {
|
|||
IDeckLinkConfiguration *config;
|
||||
IDeckLinkAttributes *attributes;
|
||||
GstClock *clock;
|
||||
GstClockTime clock_start_time, clock_offset, clock_last_time;
|
||||
GstClockTime clock_start_time, clock_offset, clock_last_time, clock_epoch;
|
||||
gboolean started, clock_restart;
|
||||
|
||||
/* Everything below protected by mutex */
|
||||
|
|
|
@ -558,6 +558,7 @@ gst_decklink_video_sink_open (GstBaseSink * bsink)
|
|||
self->output->start_scheduled_playback =
|
||||
gst_decklink_video_sink_start_scheduled_playback;
|
||||
self->output->clock_start_time = GST_CLOCK_TIME_NONE;
|
||||
self->output->clock_epoch += self->output->clock_last_time;
|
||||
self->output->clock_last_time = 0;
|
||||
self->output->clock_offset = 0;
|
||||
g_mutex_unlock (&self->output->lock);
|
||||
|
@ -706,6 +707,7 @@ gst_decklink_video_sink_change_state (GstElement * element,
|
|||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
g_mutex_lock (&self->output->lock);
|
||||
self->output->clock_start_time = GST_CLOCK_TIME_NONE;
|
||||
self->output->clock_epoch += self->output->clock_last_time;
|
||||
self->output->clock_last_time = 0;
|
||||
self->output->clock_offset = 0;
|
||||
g_mutex_unlock (&self->output->lock);
|
||||
|
@ -746,6 +748,7 @@ gst_decklink_video_sink_change_state (GstElement * element,
|
|||
gst_clock_set_calibration (self->output->clock, 0, 0, 1, 1);
|
||||
g_mutex_lock (&self->output->lock);
|
||||
self->output->clock_start_time = GST_CLOCK_TIME_NONE;
|
||||
self->output->clock_epoch += self->output->clock_last_time;
|
||||
self->output->clock_last_time = 0;
|
||||
self->output->clock_offset = 0;
|
||||
g_mutex_unlock (&self->output->lock);
|
||||
|
|
|
@ -645,6 +645,7 @@ gst_decklink_video_src_open (GstDecklinkVideoSrc * self)
|
|||
self->input->got_video_frame = gst_decklink_video_src_got_frame;
|
||||
self->input->start_streams = gst_decklink_video_src_start_streams;
|
||||
self->input->clock_start_time = GST_CLOCK_TIME_NONE;
|
||||
self->input->clock_epoch += self->input->clock_last_time;
|
||||
self->input->clock_last_time = 0;
|
||||
self->input->clock_offset = 0;
|
||||
g_mutex_unlock (&self->input->lock);
|
||||
|
@ -752,6 +753,7 @@ gst_decklink_video_src_change_state (GstElement * element,
|
|||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
g_mutex_lock (&self->input->lock);
|
||||
self->input->clock_start_time = GST_CLOCK_TIME_NONE;
|
||||
self->input->clock_epoch += self->input->clock_last_time;
|
||||
self->input->clock_last_time = 0;
|
||||
self->input->clock_offset = 0;
|
||||
g_mutex_unlock (&self->input->lock);
|
||||
|
@ -790,6 +792,7 @@ gst_decklink_video_src_change_state (GstElement * element,
|
|||
gst_clock_set_calibration (self->input->clock, 0, 0, 1, 1);
|
||||
g_mutex_lock (&self->input->lock);
|
||||
self->input->clock_start_time = GST_CLOCK_TIME_NONE;
|
||||
self->input->clock_epoch += self->input->clock_last_time;
|
||||
self->input->clock_last_time = 0;
|
||||
self->input->clock_offset = 0;
|
||||
g_mutex_unlock (&self->input->lock);
|
||||
|
|
Loading…
Reference in a new issue