From 5230cab38d22b861fec54174c9285fb4c2f10cef Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fran=C3=A7ois=20Laignel?= Date: Wed, 16 Jun 2021 11:59:20 +0200 Subject: [PATCH] Check mandatory ClockTime arguments Part-of: --- gst/gstclock.c | 10 ++++++++++ gst/gstcontrolbinding.c | 1 + gst/gstcontrolsource.c | 3 +++ gst/gstelement.c | 1 + gst/gstevent.c | 2 ++ gst/gstmessage.c | 2 ++ libs/gst/base/gstbaseparse.c | 4 +++- libs/gst/base/gstbasesink.c | 1 + libs/gst/base/gstbasetransform.c | 1 + libs/gst/check/gstharness.c | 5 +++-- 10 files changed, 27 insertions(+), 3 deletions(-) diff --git a/gst/gstclock.c b/gst/gstclock.c index 11a0290..9a83cc9 100644 --- a/gst/gstclock.c +++ b/gst/gstclock.c @@ -310,6 +310,8 @@ gboolean gst_clock_single_shot_id_reinit (GstClock * clock, GstClockID id, GstClockTime time) { + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (time), FALSE); + return gst_clock_entry_reinit (clock, (GstClockEntry *) id, time, GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE); } @@ -331,6 +333,9 @@ gboolean gst_clock_periodic_id_reinit (GstClock * clock, GstClockID id, GstClockTime start_time, GstClockTime interval) { + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (start_time), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (interval), FALSE); + return gst_clock_entry_reinit (clock, (GstClockEntry *) id, start_time, interval, GST_CLOCK_ENTRY_PERIODIC); } @@ -412,6 +417,7 @@ GstClockID gst_clock_new_single_shot_id (GstClock * clock, GstClockTime time) { g_return_val_if_fail (GST_IS_CLOCK (clock), NULL); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (time), NULL); return gst_clock_entry_new (clock, time, GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE); @@ -1147,6 +1153,8 @@ gst_clock_set_calibration (GstClock * clock, GstClockTime internal, GstClockTime GstClockPrivate *priv; g_return_if_fail (GST_IS_CLOCK (clock)); + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (internal)); + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (external)); g_return_if_fail (rate_num != GST_CLOCK_TIME_NONE); g_return_if_fail (rate_denom > 0 && rate_denom != GST_CLOCK_TIME_NONE); @@ -1474,6 +1482,8 @@ gst_clock_add_observation_unapplied (GstClock * clock, GstClockTime slave, guint n; g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (slave), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (master), FALSE); g_return_val_if_fail (r_squared != NULL, FALSE); priv = clock->priv; diff --git a/gst/gstcontrolbinding.c b/gst/gstcontrolbinding.c index 83caa51..42c32f1 100644 --- a/gst/gstcontrolbinding.c +++ b/gst/gstcontrolbinding.c @@ -260,6 +260,7 @@ gst_control_binding_sync_values (GstControlBinding * binding, gboolean ret = FALSE; g_return_val_if_fail (GST_IS_CONTROL_BINDING (binding), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); if (binding->disabled) return TRUE; diff --git a/gst/gstcontrolsource.c b/gst/gstcontrolsource.c index 1817edc..04271be 100644 --- a/gst/gstcontrolsource.c +++ b/gst/gstcontrolsource.c @@ -84,6 +84,7 @@ gst_control_source_get_value (GstControlSource * self, GstClockTime timestamp, gdouble * value) { g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); if (G_LIKELY (self->get_value)) { return self->get_value (self, timestamp, value); @@ -112,6 +113,8 @@ gst_control_source_get_value_array (GstControlSource * self, gdouble * values) { g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp), FALSE); + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (interval), FALSE); if (G_LIKELY (self->get_value_array)) { return self->get_value_array (self, timestamp, interval, n_values, values); diff --git a/gst/gstelement.c b/gst/gstelement.c index 48e4182..82244a8 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -488,6 +488,7 @@ gst_element_set_base_time (GstElement * element, GstClockTime time) GstClockTime old; g_return_if_fail (GST_IS_ELEMENT (element)); + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (time)); GST_OBJECT_LOCK (element); old = element->base_time; diff --git a/gst/gstevent.c b/gst/gstevent.c index 036c4f4..9ace25a 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -1518,6 +1518,8 @@ gst_event_new_latency (GstClockTime latency) GstEvent *event; GstStructure *structure; + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (latency), NULL); + GST_CAT_INFO (GST_CAT_EVENT, "creating latency event %" GST_TIME_FORMAT, GST_TIME_ARGS (latency)); diff --git a/gst/gstmessage.c b/gst/gstmessage.c index 26cf379..f3f2007 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -2354,6 +2354,8 @@ gst_message_new_reset_time (GstObject * src, GstClockTime running_time) GstMessage *message; GstStructure *structure; + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (running_time), NULL); + structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME), GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL); message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure); diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index f1f3479..b08a284 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -1994,6 +1994,8 @@ gst_base_parse_add_index_entry (GstBaseParse * parse, guint64 offset, gboolean ret = FALSE; GstIndexAssociation associations[2]; + g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (ts), FALSE); + GST_LOG_OBJECT (parse, "Adding key=%d index entry %" GST_TIME_FORMAT " @ offset 0x%08" G_GINT64_MODIFIER "x", key, GST_TIME_ARGS (ts), offset); @@ -4076,7 +4078,7 @@ void gst_base_parse_set_latency (GstBaseParse * parse, GstClockTime min_latency, GstClockTime max_latency) { - g_return_if_fail (min_latency != GST_CLOCK_TIME_NONE); + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (min_latency)); g_return_if_fail (min_latency <= max_latency); GST_OBJECT_LOCK (parse); diff --git a/libs/gst/base/gstbasesink.c b/libs/gst/base/gstbasesink.c index b5b5f13..c94bbac 100644 --- a/libs/gst/base/gstbasesink.c +++ b/libs/gst/base/gstbasesink.c @@ -1327,6 +1327,7 @@ gst_base_sink_set_render_delay (GstBaseSink * sink, GstClockTime delay) GstClockTime old_render_delay; g_return_if_fail (GST_IS_BASE_SINK (sink)); + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (delay)); GST_OBJECT_LOCK (sink); old_render_delay = sink->priv->render_delay; diff --git a/libs/gst/base/gstbasetransform.c b/libs/gst/base/gstbasetransform.c index f963046..e4e7ee6 100644 --- a/libs/gst/base/gstbasetransform.c +++ b/libs/gst/base/gstbasetransform.c @@ -2696,6 +2696,7 @@ gst_base_transform_update_qos (GstBaseTransform * trans, gdouble proportion, GstClockTimeDiff diff, GstClockTime timestamp) { g_return_if_fail (GST_IS_BASE_TRANSFORM (trans)); + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (timestamp)); GST_CAT_DEBUG_OBJECT (GST_CAT_QOS, trans, "qos: proportion: %lf, diff %" G_GINT64_FORMAT ", timestamp %" diff --git a/libs/gst/check/gstharness.c b/libs/gst/check/gstharness.c index 7d4b260..fc1ab0d 100644 --- a/libs/gst/check/gstharness.c +++ b/libs/gst/check/gstharness.c @@ -2226,8 +2226,9 @@ gst_harness_query_latency (GstHarness * h) void gst_harness_set_upstream_latency (GstHarness * h, GstClockTime latency) { - GstHarnessPrivate *priv = h->priv; - priv->latency_min = latency; + g_return_if_fail (GST_CLOCK_TIME_IS_VALID (latency)); + + h->priv->latency_min = latency; } /** -- 2.7.4