GST_DEFINE_MINI_OBJECT_TYPE (GstValidateAction, gst_validate_action);
static GstValidateAction *gst_validate_action_new (GstValidateScenario *
scenario, GstValidateActionType * type);
-static gboolean get_position (GstValidateScenario * scenario);
+static gboolean execute_next_action (GstValidateScenario * scenario);
static GstValidateAction *
_action_copy (GstValidateAction * act)
}
static inline gboolean
-_add_get_position_source (GstValidateScenario * scenario)
+_add_execute_actions_gsource (GstValidateScenario * scenario)
{
GstValidateScenarioPrivate *priv = scenario->priv;
SCENARIO_LOCK (scenario);
if (priv->get_pos_id == 0 && priv->wait_id == 0) {
- priv->get_pos_id = g_idle_add ((GSourceFunc) get_position, scenario);
+ priv->get_pos_id = g_idle_add ((GSourceFunc) execute_next_action, scenario);
SCENARIO_UNLOCK (scenario);
GST_DEBUG_OBJECT (scenario, "Start checking position again");
return GST_VALIDATE_EXECUTE_ACTION_OK;
}
+
+/* This is the main action execution function
+ * it checks whether it is time to run the next action
+ * and if it is the case executes it.
+ *
+ * If the 'execute-on-idle' property is not TRUE,
+ * the function will recurse while the actions are run
+ * synchronously
+ */
static gboolean
-get_position (GstValidateScenario * scenario)
+execute_next_action (GstValidateScenario * scenario)
{
GList *tmp;
GstQuery *query;
if (priv->buffering) {
GST_DEBUG_OBJECT (scenario, "Buffering not executing any action");
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
if (priv->changing_state) {
GST_DEBUG_OBJECT (scenario, "Changing state, not executing any action");
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
/* TODO what about non flushing seeks? */
if (priv->last_seek && priv->target_state > GST_STATE_READY) {
GST_INFO_OBJECT (scenario, "Still seeking -- not executing action");
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
if (scenario->priv->actions)
GST_DEBUG_OBJECT (scenario, "Action %" GST_PTR_FORMAT " still running",
act->structure);
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
}
act && GST_CLOCK_TIME_IS_VALID (act->playback_time)) {
GST_INFO_OBJECT (scenario, "Unknown position: %" GST_TIME_FORMAT,
GST_TIME_ARGS (position));
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
if (has_pos && has_dur) {
if (position > duration) {
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
GST_VALIDATE_REPORT (scenario,
QUERY_POSITION_SUPERIOR_DURATION,
"Reported position %" GST_TIME_FORMAT " > reported duration %"
GST_TIME_FORMAT, GST_TIME_ARGS (position), GST_TIME_ARGS (duration));
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
}
_check_position (scenario, rate, position);
if (!_should_execute_action (scenario, act, position, rate)) {
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
type = _find_action_type (act->type);
if (!scenario->priv->execute_on_idle) {
GST_DEBUG_OBJECT (scenario, "linking next action execution");
- return get_position (scenario);
+ return execute_next_action (scenario);
} else {
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
GST_DEBUG_OBJECT (scenario, "Executing only on idle, waiting for"
" next dispatch");
- return TRUE;
+ return G_SOURCE_REMOVE;
}
} else {
GST_DEBUG_OBJECT (scenario, "Remove source, waiting for action"
priv->get_pos_id = 0;
SCENARIO_UNLOCK (scenario);
- return G_SOURCE_REMOVE;
+ return G_SOURCE_CONTINUE;
}
- return TRUE;
+ return G_SOURCE_CONTINUE;
}
static gboolean
SCENARIO_UNLOCK (scenario);
gst_validate_action_set_done (action);
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
return G_SOURCE_REMOVE;
g_list_free (priv->needs_parsing);
priv->needs_parsing = NULL;
}
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
break;
case GST_MESSAGE_STATE_CHANGED:
{
}
if (pstate == GST_STATE_READY && nstate == GST_STATE_PAUSED)
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
}
break;
}
if (scenario->priv->handles_state) {
GST_INFO_OBJECT (scenario, "Scenario handles state,"
" Starting the get position source");
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
}
gst_validate_printf (NULL,
if (GPOINTER_TO_INT (g_private_get (&main_thread_priv))) {
if (!scenario->priv->execute_on_idle) {
GST_DEBUG_OBJECT (scenario, "Right thread, executing next?");
- get_position (scenario);
+ execute_next_action (scenario);
return;
} else
" 'main' thread");
}
- _add_get_position_source (scenario);
+ _add_execute_actions_gsource (scenario);
}
/**