From 7ceb6227ac67181a23a088ce6cc60509c9e15ed1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 7 Dec 2005 15:33:42 +0000 Subject: [PATCH] plugins/elements/gstfakesrc.c: Fix broken sync option, fixes #323259 Original commit message from CVS: * plugins/elements/gstfakesrc.c: (gst_fake_src_class_init), (gst_fake_src_get_times), (gst_fake_src_create): Fix broken sync option, fixes #323259 --- ChangeLog | 6 ++++++ plugins/elements/gstfakesrc.c | 35 +++++++++++++++++++++++++++++++---- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index bd9c27a40e..ccd373ffa0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-12-07 Wim Taymans + + * plugins/elements/gstfakesrc.c: (gst_fake_src_class_init), + (gst_fake_src_get_times), (gst_fake_src_create): + Fix broken sync option, fixes #323259 + 2005-12-07 Wim Taymans * gst/gstbuffer.c: diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c index 32fa8d1104..cc3b2e4131 100644 --- a/plugins/elements/gstfakesrc.c +++ b/plugins/elements/gstfakesrc.c @@ -23,7 +23,7 @@ * SECTION:element-fakesrc * @short_description: Generate (meaningless) buffers * @see_also: #GstFakeSink - * + * * * * The fakesrc element is a multipurpose element that can generate @@ -225,6 +225,8 @@ static gboolean gst_fake_src_stop (GstBaseSrc * basesrc); static gboolean gst_fake_src_is_seekable (GstBaseSrc * basesrc); static gboolean gst_fake_src_event_handler (GstBaseSrc * src, GstEvent * event); +static void gst_fake_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer, + GstClockTime * start, GstClockTime * end); static GstFlowReturn gst_fake_src_create (GstBaseSrc * src, guint64 offset, guint length, GstBuffer ** buf); @@ -340,6 +342,7 @@ gst_fake_src_class_init (GstFakeSrcClass * klass) gstbase_src_class->start = GST_DEBUG_FUNCPTR (gst_fake_src_start); gstbase_src_class->stop = GST_DEBUG_FUNCPTR (gst_fake_src_stop); gstbase_src_class->event = GST_DEBUG_FUNCPTR (gst_fake_src_event_handler); + gstbase_src_class->get_times = GST_DEBUG_FUNCPTR (gst_fake_src_get_times); gstbase_src_class->create = GST_DEBUG_FUNCPTR (gst_fake_src_create); } @@ -698,6 +701,33 @@ gst_fake_src_create_buffer (GstFakeSrc * src) return buf; } +static void +gst_fake_src_get_times (GstBaseSrc * basesrc, GstBuffer * buffer, + GstClockTime * start, GstClockTime * end) +{ + GstFakeSrc *src; + + src = GST_FAKE_SRC (basesrc); + + /* sync on the timestamp of the buffer if requested. */ + if (src->sync) { + GstClockTime timestamp = GST_BUFFER_TIMESTAMP (buffer); + + if (GST_CLOCK_TIME_IS_VALID (timestamp)) { + /* get duration to calculate end time */ + GstClockTime duration = GST_BUFFER_DURATION (buffer); + + if (GST_CLOCK_TIME_IS_VALID (duration)) { + *end = timestamp + duration; + } + *start = timestamp; + } + } else { + *start = -1; + *end = -1; + } +} + static GstFlowReturn gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GstBuffer ** ret) @@ -713,9 +743,6 @@ gst_fake_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, if (src->datarate > 0) { time = (src->bytes_sent * GST_SECOND) / src->datarate; - if (src->sync) { - /* gst_element_wait (GST_ELEMENT (src), time); */ - } GST_BUFFER_DURATION (buf) = GST_BUFFER_SIZE (buf) * GST_SECOND / src->datarate;