mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 06:54:49 +00:00
validate:scenario: Add a way to define a timeout for actions execution
Reviewers: Mathieu_Du Differential Revision: https://phabricator.freedesktop.org/D271
This commit is contained in:
parent
67d53d6aad
commit
f69b63e749
3 changed files with 31 additions and 6 deletions
|
@ -322,6 +322,8 @@ gst_validate_report_load_issues (void)
|
||||||
"segment"), NULL);
|
"segment"), NULL);
|
||||||
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_NOT_ENDED,
|
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_NOT_ENDED,
|
||||||
_("All the actions were not executed before the program stopped"), NULL);
|
_("All the actions were not executed before the program stopped"), NULL);
|
||||||
|
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_TIMEOUT,
|
||||||
|
_("The execution of an action timed out"), NULL);
|
||||||
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_FILE_MALFORMED,
|
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_FILE_MALFORMED,
|
||||||
_("The scenario file was malformed"), NULL);
|
_("The scenario file was malformed"), NULL);
|
||||||
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_EXECUTION_ERROR,
|
REGISTER_VALIDATE_ISSUE (CRITICAL, SCENARIO_ACTION_EXECUTION_ERROR,
|
||||||
|
|
|
@ -110,6 +110,7 @@ typedef enum {
|
||||||
#define SCENARIO_NOT_ENDED _QUARK("scenario::not-ended")
|
#define SCENARIO_NOT_ENDED _QUARK("scenario::not-ended")
|
||||||
#define SCENARIO_FILE_MALFORMED _QUARK("scenario::malformed")
|
#define SCENARIO_FILE_MALFORMED _QUARK("scenario::malformed")
|
||||||
#define SCENARIO_ACTION_EXECUTION_ERROR _QUARK("scenario::execution-error")
|
#define SCENARIO_ACTION_EXECUTION_ERROR _QUARK("scenario::execution-error")
|
||||||
|
#define SCENARIO_ACTION_TIMEOUT _QUARK("scenario::action-timeout")
|
||||||
#define SCENARIO_ACTION_EXECUTION_ISSUE _QUARK("scenario::execution-issue")
|
#define SCENARIO_ACTION_EXECUTION_ISSUE _QUARK("scenario::execution-issue")
|
||||||
|
|
||||||
#define G_LOG_ISSUE _QUARK("g-log::issue")
|
#define G_LOG_ISSUE _QUARK("g-log::issue")
|
||||||
|
|
|
@ -190,6 +190,9 @@ struct _GstValidateActionPrivate
|
||||||
gboolean executing_last_subaction;
|
gboolean executing_last_subaction;
|
||||||
gboolean optional;
|
gboolean optional;
|
||||||
|
|
||||||
|
GstClockTime execution_time;
|
||||||
|
GstClockTime timeout;
|
||||||
|
|
||||||
GWeakRef scenario;
|
GWeakRef scenario;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -216,6 +219,7 @@ _action_copy (GstValidateAction * act)
|
||||||
|
|
||||||
copy->action_number = act->action_number;
|
copy->action_number = act->action_number;
|
||||||
copy->playback_time = act->playback_time;
|
copy->playback_time = act->playback_time;
|
||||||
|
copy->priv->timeout = act->priv->timeout;
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
}
|
}
|
||||||
|
@ -265,6 +269,7 @@ gst_validate_action_new (GstValidateScenario * scenario,
|
||||||
|
|
||||||
gst_validate_action_init (action);
|
gst_validate_action_init (action);
|
||||||
action->playback_time = GST_CLOCK_TIME_NONE;
|
action->playback_time = GST_CLOCK_TIME_NONE;
|
||||||
|
action->priv->timeout = GST_CLOCK_TIME_NONE;
|
||||||
action->type = action_type->name;
|
action->type = action_type->name;
|
||||||
action->repeat = -1;
|
action->repeat = -1;
|
||||||
|
|
||||||
|
@ -1163,6 +1168,7 @@ gst_validate_execute_action (GstValidateActionType * action_type,
|
||||||
|
|
||||||
gst_validate_print_action (action, NULL);
|
gst_validate_print_action (action, NULL);
|
||||||
|
|
||||||
|
action->priv->execution_time = gst_util_get_timestamp ();
|
||||||
res = action_type->execute (action->scenario, action);
|
res = action_type->execute (action->scenario, action);
|
||||||
|
|
||||||
if (!gst_structure_has_field (action->structure, "sub-action")) {
|
if (!gst_structure_has_field (action->structure, "sub-action")) {
|
||||||
|
@ -1237,6 +1243,12 @@ _fill_action (GstValidateScenario * scenario, GstValidateAction * action,
|
||||||
GST_INFO_OBJECT (scenario,
|
GST_INFO_OBJECT (scenario,
|
||||||
"No playback time for action %" GST_PTR_FORMAT, structure);
|
"No playback time for action %" GST_PTR_FORMAT, structure);
|
||||||
|
|
||||||
|
if (!gst_validate_utils_get_clocktime (structure,
|
||||||
|
"timeout", &action->priv->timeout)) {
|
||||||
|
GST_INFO_OBJECT (scenario,
|
||||||
|
"No timeout time for action %" GST_PTR_FORMAT, structure);
|
||||||
|
}
|
||||||
|
|
||||||
if (!(action->name = gst_structure_get_string (structure, "name")))
|
if (!(action->name = gst_structure_get_string (structure, "name")))
|
||||||
action->name = "";
|
action->name = "";
|
||||||
|
|
||||||
|
@ -1378,12 +1390,6 @@ execute_next_action (GstValidateScenario * scenario)
|
||||||
return G_SOURCE_CONTINUE;
|
return G_SOURCE_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO what about non flushing seeks? */
|
|
||||||
if (priv->last_seek && priv->target_state > GST_STATE_READY) {
|
|
||||||
GST_LOG_OBJECT (scenario, "Still seeking -- not executing action");
|
|
||||||
return G_SOURCE_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scenario->priv->actions)
|
if (scenario->priv->actions)
|
||||||
act = scenario->priv->actions->data;
|
act = scenario->priv->actions->data;
|
||||||
|
|
||||||
|
@ -1405,6 +1411,21 @@ execute_next_action (GstValidateScenario * scenario)
|
||||||
act = NULL;
|
act = NULL;
|
||||||
}
|
}
|
||||||
} else if (act->priv->state == GST_VALIDATE_EXECUTE_ACTION_ASYNC) {
|
} else if (act->priv->state == GST_VALIDATE_EXECUTE_ACTION_ASYNC) {
|
||||||
|
if (GST_CLOCK_TIME_IS_VALID (act->priv->timeout)) {
|
||||||
|
GstClockTime etime =
|
||||||
|
gst_util_get_timestamp () - act->priv->execution_time;
|
||||||
|
|
||||||
|
if (etime > act->priv->timeout) {
|
||||||
|
gchar *str = gst_structure_to_string (act->structure);
|
||||||
|
|
||||||
|
GST_VALIDATE_REPORT (scenario,
|
||||||
|
SCENARIO_ACTION_EXECUTION_ERROR,
|
||||||
|
"Action %s timed out after: %" GST_TIME_FORMAT, str,
|
||||||
|
GST_TIME_ARGS (etime));
|
||||||
|
|
||||||
|
g_free (str);
|
||||||
|
}
|
||||||
|
}
|
||||||
GST_LOG_OBJECT (scenario, "Action %" GST_PTR_FORMAT " still running",
|
GST_LOG_OBJECT (scenario, "Action %" GST_PTR_FORMAT " still running",
|
||||||
act->structure);
|
act->structure);
|
||||||
|
|
||||||
|
@ -2920,6 +2941,7 @@ _action_set_done (GstValidateAction * action)
|
||||||
if (action->scenario == NULL)
|
if (action->scenario == NULL)
|
||||||
return G_SOURCE_REMOVE;
|
return G_SOURCE_REMOVE;
|
||||||
|
|
||||||
|
action->priv->execution_time = GST_CLOCK_TIME_NONE;
|
||||||
action->priv->state = _execute_sub_action_action (action);
|
action->priv->state = _execute_sub_action_action (action);
|
||||||
if (action->priv->state != GST_VALIDATE_EXECUTE_ACTION_ASYNC) {
|
if (action->priv->state != GST_VALIDATE_EXECUTE_ACTION_ASYNC) {
|
||||||
GST_DEBUG_OBJECT (action->scenario, "Sub action executed ASYNC");
|
GST_DEBUG_OBJECT (action->scenario, "Sub action executed ASYNC");
|
||||||
|
|
Loading…
Reference in a new issue