diff --git a/sys/decklink/gstdecklinkaudiosrc.cpp b/sys/decklink/gstdecklinkaudiosrc.cpp index 2fef934c89..779cbc8a42 100644 --- a/sys/decklink/gstdecklinkaudiosrc.cpp +++ b/sys/decklink/gstdecklinkaudiosrc.cpp @@ -237,6 +237,10 @@ gst_decklink_audio_src_init (GstDecklinkAudioSrc * self) self->current_packets = gst_queue_array_new_for_struct (sizeof (CapturePacket), DEFAULT_BUFFER_SIZE); + + self->skipped_last = 0; + self->skip_from_timestamp = GST_CLOCK_TIME_NONE; + self->skip_to_timestamp = GST_CLOCK_TIME_NONE; } void @@ -526,25 +530,31 @@ gst_decklink_audio_src_got_packet (GstElement * element, if (!self->flushing) { CapturePacket p; guint skipped_packets = 0; - GstClockTime from_timestamp = GST_CLOCK_TIME_NONE; - GstClockTime to_timestamp = GST_CLOCK_TIME_NONE; while (gst_queue_array_get_length (self->current_packets) >= self->buffer_size) { CapturePacket *tmp = (CapturePacket *) gst_queue_array_pop_head_struct (self->current_packets); - if (skipped_packets == 0) - from_timestamp = tmp->timestamp; + if (skipped_packets == 0 && self->skipped_last == 0) + self->skip_from_timestamp = tmp->timestamp; skipped_packets++; - to_timestamp = tmp->timestamp; + self->skip_to_timestamp = tmp->timestamp; capture_packet_clear (tmp); } - if (skipped_packets > 0) + if (self->skipped_last == 0 && skipped_packets > 0) { + GST_WARNING_OBJECT (self, "Starting to drop audio packets"); + } + + if (skipped_packets == 0 && self->skipped_last > 0) { GST_WARNING_OBJECT (self, "Dropped %u old packets from %" GST_TIME_FORMAT " to %" - GST_TIME_FORMAT, skipped_packets, GST_TIME_ARGS (from_timestamp), - GST_TIME_ARGS (to_timestamp)); + GST_TIME_FORMAT, self->skipped_last, + GST_TIME_ARGS (self->skip_from_timestamp), + GST_TIME_ARGS (self->skip_to_timestamp)); + self->skipped_last = 0; + } + self->skipped_last += skipped_packets; memset (&p, 0, sizeof (p)); p.packet = packet; diff --git a/sys/decklink/gstdecklinkaudiosrc.h b/sys/decklink/gstdecklinkaudiosrc.h index 405da7ae50..fdb77b622c 100644 --- a/sys/decklink/gstdecklinkaudiosrc.h +++ b/sys/decklink/gstdecklinkaudiosrc.h @@ -81,6 +81,10 @@ struct _GstDecklinkAudioSrc GstClockTime discont_time; guint buffer_size; + + guint skipped_last; + GstClockTime skip_from_timestamp; + GstClockTime skip_to_timestamp; }; struct _GstDecklinkAudioSrcClass diff --git a/sys/decklink/gstdecklinkvideosrc.cpp b/sys/decklink/gstdecklinkvideosrc.cpp index b30f442fab..e6e2989330 100644 --- a/sys/decklink/gstdecklinkvideosrc.cpp +++ b/sys/decklink/gstdecklinkvideosrc.cpp @@ -408,6 +408,9 @@ gst_decklink_video_src_init (GstDecklinkVideoSrc * self) self->window_fill = 0; self->window_skip = 1; self->window_skip_count = 0; + self->skipped_last = 0; + self->skip_from_timestamp = GST_CLOCK_TIME_NONE; + self->skip_to_timestamp = GST_CLOCK_TIME_NONE; gst_base_src_set_live (GST_BASE_SRC (self), TRUE); gst_base_src_set_format (GST_BASE_SRC (self), GST_FORMAT_TIME); @@ -837,27 +840,34 @@ gst_decklink_video_src_got_frame (GstElement * element, GstVideoTimeCodeFlags flags = GST_VIDEO_TIME_CODE_FLAGS_NONE; guint field_count = 0; guint skipped_frames = 0; - GstClockTime from_timestamp = GST_CLOCK_TIME_NONE; - GstClockTime to_timestamp = GST_CLOCK_TIME_NONE; while (gst_queue_array_get_length (self->current_frames) >= self->buffer_size) { CaptureFrame *tmp = (CaptureFrame *) gst_queue_array_pop_head_struct (self->current_frames); if (tmp->frame) { - if (skipped_frames == 0) - from_timestamp = tmp->timestamp; + if (skipped_frames == 0 && self->skipped_last == 0) + self->skip_from_timestamp = tmp->timestamp; skipped_frames++; - to_timestamp = tmp->timestamp; + self->skip_to_timestamp = tmp->timestamp; } capture_frame_clear (tmp); } - if (skipped_frames > 0) + if (self->skipped_last == 0 && skipped_frames > 0) { + GST_WARNING_OBJECT (self, "Starting to drop frames"); + } + + if (skipped_frames == 0 && self->skipped_last > 0) { GST_WARNING_OBJECT (self, "Dropped %u old frames from %" GST_TIME_FORMAT " to %" - GST_TIME_FORMAT, skipped_frames, GST_TIME_ARGS (from_timestamp), - GST_TIME_ARGS (to_timestamp)); + GST_TIME_FORMAT, self->skipped_last, + GST_TIME_ARGS (self->skip_from_timestamp), + GST_TIME_ARGS (self->skip_to_timestamp)); + self->skipped_last = 0; + } + + self->skipped_last += skipped_frames; memset (&f, 0, sizeof (f)); f.frame = frame; diff --git a/sys/decklink/gstdecklinkvideosrc.h b/sys/decklink/gstdecklinkvideosrc.h index a56d6ca50c..b4f0e7bbfc 100644 --- a/sys/decklink/gstdecklinkvideosrc.h +++ b/sys/decklink/gstdecklinkvideosrc.h @@ -111,6 +111,10 @@ struct _GstDecklinkVideoSrc gboolean output_afd_bar; gint last_afd_bar_vbi_line; gint last_afd_bar_vbi_line_field2; + + guint skipped_last; + GstClockTime skip_from_timestamp; + GstClockTime skip_to_timestamp; }; struct _GstDecklinkVideoSrcClass