diff options
author | Sebastian Dröge <sebastian@centricular.com> | 2015-08-17 14:27:33 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2015-08-17 14:27:33 +0200 |
commit | 403b23642603710404d4fdcedc89727220a3b8e8 (patch) | |
tree | b3228f547dac756ba43e8241fab38f05e0ef8c13 | |
parent | 09c528369211100744a28c939b58bcbc7e5f2f1b (diff) |
validate: Don't override the target state of the scenario when receiving BUFFERING=100%
If the scenario handles the states and wants to stay in PAUSED, it's not a
good idea to change the state to PLAYING when receiving BUFFERING=100%. This
caused a race condition in varios seeking tests, most often in the dash scrub
seeking test.
-rw-r--r-- | validate/gst/validate/gst-validate-scenario.c | 15 | ||||
-rw-r--r-- | validate/gst/validate/gst-validate-scenario.h | 3 | ||||
-rw-r--r-- | validate/tools/gst-validate.c | 35 |
3 files changed, 49 insertions, 4 deletions
diff --git a/validate/gst/validate/gst-validate-scenario.c b/validate/gst/validate/gst-validate-scenario.c index ab9f073..5d4e36f 100644 --- a/validate/gst/validate/gst-validate-scenario.c +++ b/validate/gst/validate/gst-validate-scenario.c @@ -582,6 +582,7 @@ _pause_action_restore_playing (GstValidateScenario * scenario) GST_STATE_CHANGE_FAILURE) { GST_VALIDATE_REPORT (scenario, STATE_CHANGE_FAILURE, "Failed to set state to playing"); + scenario->priv->target_state = GST_STATE_PLAYING; } return FALSE; @@ -3202,6 +3203,20 @@ gst_validate_scenario_get_actions (GstValidateScenario * scenario) return ret; } +/** + * gst_validate_scenario_get_target_state: + * @scenario: The scenario to retrieve the current target state for + * + * Get current target state from @scenario. + * + * Returns: Current target state. + */ +GstState +gst_validate_scenario_get_target_state (GstValidateScenario * scenario) +{ + return scenario->priv->target_state; +} + void init_scenarios (void) { diff --git a/validate/gst/validate/gst-validate-scenario.h b/validate/gst/validate/gst-validate-scenario.h index ecfe013..84af999 100644 --- a/validate/gst/validate/gst-validate-scenario.h +++ b/validate/gst/validate/gst-validate-scenario.h @@ -308,6 +308,9 @@ GstValidateExecuteActionReturn gst_validate_execute_action (GstValidateActionType * action_type, GstValidateAction * action); +GstState +gst_validate_scenario_get_target_state (GstValidateScenario *scenario); + G_END_DECLS #endif /* __GST_VALIDATE_SCENARIOS__ */ diff --git a/validate/tools/gst-validate.c b/validate/tools/gst-validate.c index 5d70d28..994f36e 100644 --- a/validate/tools/gst-validate.c +++ b/validate/tools/gst-validate.c @@ -34,6 +34,7 @@ #include <gst/validate/gst-validate-scenario.h> #include <gst/validate/gst-validate-utils.h> #include <gst/validate/media-descriptor-parser.h> +#include <gst/validate/gst-validate-bin-monitor.h> #ifdef G_OS_UNIX #include <glib-unix.h> @@ -65,10 +66,18 @@ intr_handler (gpointer user_data) } #endif /* G_OS_UNIX */ +typedef struct +{ + GMainLoop *mainloop; + GstValidateMonitor *monitor; +} BusCallbackData; + static gboolean bus_callback (GstBus * bus, GstMessage * message, gpointer data) { - GMainLoop *loop = data; + BusCallbackData *bus_callback_data = data; + GMainLoop *loop = bus_callback_data->mainloop; + GstValidateMonitor *monitor = bus_callback_data->monitor; switch (GST_MESSAGE_TYPE (message)) { case GST_MESSAGE_ERROR: @@ -135,6 +144,15 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) case GST_MESSAGE_BUFFERING:{ gint percent; GstBufferingMode mode; + GstState target_state = GST_STATE_PLAYING; + gboolean monitor_handles_state; + + g_object_get (monitor, "handles-states", &monitor_handles_state, NULL); + if (monitor_handles_state && GST_IS_VALIDATE_BIN_MONITOR (monitor)) { + target_state = + gst_validate_scenario_get_target_state (GST_VALIDATE_BIN_MONITOR + (monitor)->scenario); + } if (!buffering) { g_print ("\n"); @@ -154,8 +172,13 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) /* a 100% message means buffering is done */ if (buffering) { buffering = FALSE; - g_print ("Done buffering, setting pipeline to PLAYING\n"); - gst_element_set_state (pipeline, GST_STATE_PLAYING); + + if (target_state == GST_STATE_PLAYING) { + g_print ("Done buffering, setting pipeline to PLAYING\n"); + gst_element_set_state (pipeline, GST_STATE_PLAYING); + } else { + g_print ("Done buffering, staying in PAUSED\n"); + } } } else { /* buffering... */ @@ -411,6 +434,7 @@ main (int argc, gchar ** argv) inspect_action_type = FALSE; GstStateChangeReturn sret; gchar *output_file = NULL; + BusCallbackData bus_callback_data = { 0, }; #ifdef G_OS_UNIX guint signal_watch_id; @@ -575,7 +599,10 @@ main (int argc, gchar ** argv) mainloop = g_main_loop_new (NULL, FALSE); bus = gst_element_get_bus (pipeline); gst_bus_add_signal_watch (bus); - g_signal_connect (bus, "message", (GCallback) bus_callback, mainloop); + bus_callback_data.mainloop = mainloop; + bus_callback_data.monitor = monitor; + g_signal_connect (bus, "message", (GCallback) bus_callback, + &bus_callback_data); g_print ("Starting pipeline\n"); g_object_get (monitor, "handles-states", &monitor_handles_state, NULL); |