Check mandatory ClockTime arguments

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/837>
This commit is contained in:
François Laignel 2021-06-16 11:59:20 +02:00
parent b16e96dd87
commit 5230cab38d
10 changed files with 27 additions and 3 deletions

View file

@ -310,6 +310,8 @@ gboolean
gst_clock_single_shot_id_reinit (GstClock * clock, GstClockID id, gst_clock_single_shot_id_reinit (GstClock * clock, GstClockID id,
GstClockTime time) GstClockTime time)
{ {
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (time), FALSE);
return gst_clock_entry_reinit (clock, (GstClockEntry *) id, time, return gst_clock_entry_reinit (clock, (GstClockEntry *) id, time,
GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE); GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE);
} }
@ -331,6 +333,9 @@ gboolean
gst_clock_periodic_id_reinit (GstClock * clock, GstClockID id, gst_clock_periodic_id_reinit (GstClock * clock, GstClockID id,
GstClockTime start_time, GstClockTime interval) 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, return gst_clock_entry_reinit (clock, (GstClockEntry *) id, start_time,
interval, GST_CLOCK_ENTRY_PERIODIC); interval, GST_CLOCK_ENTRY_PERIODIC);
} }
@ -412,6 +417,7 @@ GstClockID
gst_clock_new_single_shot_id (GstClock * clock, GstClockTime time) 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_IS_CLOCK (clock), NULL);
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (time), NULL);
return gst_clock_entry_new (clock, return gst_clock_entry_new (clock,
time, GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE); time, GST_CLOCK_TIME_NONE, GST_CLOCK_ENTRY_SINGLE);
@ -1147,6 +1153,8 @@ gst_clock_set_calibration (GstClock * clock, GstClockTime internal, GstClockTime
GstClockPrivate *priv; GstClockPrivate *priv;
g_return_if_fail (GST_IS_CLOCK (clock)); 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_num != GST_CLOCK_TIME_NONE);
g_return_if_fail (rate_denom > 0 && rate_denom != 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; guint n;
g_return_val_if_fail (GST_IS_CLOCK (clock), FALSE); 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); g_return_val_if_fail (r_squared != NULL, FALSE);
priv = clock->priv; priv = clock->priv;

View file

@ -260,6 +260,7 @@ gst_control_binding_sync_values (GstControlBinding * binding,
gboolean ret = FALSE; gboolean ret = FALSE;
g_return_val_if_fail (GST_IS_CONTROL_BINDING (binding), 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) if (binding->disabled)
return TRUE; return TRUE;

View file

@ -84,6 +84,7 @@ gst_control_source_get_value (GstControlSource * self, GstClockTime timestamp,
gdouble * value) gdouble * value)
{ {
g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE); 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)) { if (G_LIKELY (self->get_value)) {
return self->get_value (self, timestamp, value); return self->get_value (self, timestamp, value);
@ -112,6 +113,8 @@ gst_control_source_get_value_array (GstControlSource * self,
gdouble * values) gdouble * values)
{ {
g_return_val_if_fail (GST_IS_CONTROL_SOURCE (self), FALSE); 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)) { if (G_LIKELY (self->get_value_array)) {
return self->get_value_array (self, timestamp, interval, n_values, values); return self->get_value_array (self, timestamp, interval, n_values, values);

View file

@ -488,6 +488,7 @@ gst_element_set_base_time (GstElement * element, GstClockTime time)
GstClockTime old; GstClockTime old;
g_return_if_fail (GST_IS_ELEMENT (element)); g_return_if_fail (GST_IS_ELEMENT (element));
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (time));
GST_OBJECT_LOCK (element); GST_OBJECT_LOCK (element);
old = element->base_time; old = element->base_time;

View file

@ -1518,6 +1518,8 @@ gst_event_new_latency (GstClockTime latency)
GstEvent *event; GstEvent *event;
GstStructure *structure; GstStructure *structure;
g_return_val_if_fail (GST_CLOCK_TIME_IS_VALID (latency), NULL);
GST_CAT_INFO (GST_CAT_EVENT, GST_CAT_INFO (GST_CAT_EVENT,
"creating latency event %" GST_TIME_FORMAT, GST_TIME_ARGS (latency)); "creating latency event %" GST_TIME_FORMAT, GST_TIME_ARGS (latency));

View file

@ -2354,6 +2354,8 @@ gst_message_new_reset_time (GstObject * src, GstClockTime running_time)
GstMessage *message; GstMessage *message;
GstStructure *structure; 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), structure = gst_structure_new_id (GST_QUARK (MESSAGE_RESET_TIME),
GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL); GST_QUARK (RUNNING_TIME), G_TYPE_UINT64, running_time, NULL);
message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure); message = gst_message_new_custom (GST_MESSAGE_RESET_TIME, src, structure);

View file

@ -1994,6 +1994,8 @@ gst_base_parse_add_index_entry (GstBaseParse * parse, guint64 offset,
gboolean ret = FALSE; gboolean ret = FALSE;
GstIndexAssociation associations[2]; 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 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); " @ 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, gst_base_parse_set_latency (GstBaseParse * parse, GstClockTime min_latency,
GstClockTime max_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); g_return_if_fail (min_latency <= max_latency);
GST_OBJECT_LOCK (parse); GST_OBJECT_LOCK (parse);

View file

@ -1327,6 +1327,7 @@ gst_base_sink_set_render_delay (GstBaseSink * sink, GstClockTime delay)
GstClockTime old_render_delay; GstClockTime old_render_delay;
g_return_if_fail (GST_IS_BASE_SINK (sink)); g_return_if_fail (GST_IS_BASE_SINK (sink));
g_return_if_fail (GST_CLOCK_TIME_IS_VALID (delay));
GST_OBJECT_LOCK (sink); GST_OBJECT_LOCK (sink);
old_render_delay = sink->priv->render_delay; old_render_delay = sink->priv->render_delay;

View file

@ -2696,6 +2696,7 @@ gst_base_transform_update_qos (GstBaseTransform * trans,
gdouble proportion, GstClockTimeDiff diff, GstClockTime timestamp) gdouble proportion, GstClockTimeDiff diff, GstClockTime timestamp)
{ {
g_return_if_fail (GST_IS_BASE_TRANSFORM (trans)); 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, GST_CAT_DEBUG_OBJECT (GST_CAT_QOS, trans,
"qos: proportion: %lf, diff %" G_GINT64_FORMAT ", timestamp %" "qos: proportion: %lf, diff %" G_GINT64_FORMAT ", timestamp %"

View file

@ -2226,8 +2226,9 @@ gst_harness_query_latency (GstHarness * h)
void void
gst_harness_set_upstream_latency (GstHarness * h, GstClockTime latency) gst_harness_set_upstream_latency (GstHarness * h, GstClockTime latency)
{ {
GstHarnessPrivate *priv = h->priv; g_return_if_fail (GST_CLOCK_TIME_IS_VALID (latency));
priv->latency_min = latency;
h->priv->latency_min = latency;
} }
/** /**