From: Thibault Saunier Date: Sun, 19 Apr 2015 09:57:36 +0000 (+0200) Subject: validate:pipelinemonitor: Print position only when in state >= PAUSED X-Git-Tag: 1.19.3~491^2~1275 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=848d660603568302b5b81d1110c3885d0dde2adc;p=platform%2Fupstream%2Fgstreamer.git validate:pipelinemonitor: Print position only when in state >= PAUSED Reviewers: Mathieu_Du Reviewed By: Mathieu_Du Differential Revision: http://phabricator.freedesktop.org/D86 --- diff --git a/validate/gst/validate/gst-validate-pipeline-monitor.c b/validate/gst/validate/gst-validate-pipeline-monitor.c index eeb4f11..36de42d 100644 --- a/validate/gst/validate/gst-validate-pipeline-monitor.c +++ b/validate/gst/validate/gst-validate-pipeline-monitor.c @@ -47,29 +47,9 @@ G_DEFINE_TYPE (GstValidatePipelineMonitor, gst_validate_pipeline_monitor, GST_TYPE_VALIDATE_BIN_MONITOR); static void -gst_validate_pipeline_monitor_dispose (GObject * object) -{ - GstValidatePipelineMonitor *monitor = - GST_VALIDATE_PIPELINE_MONITOR_CAST (object); - - if (monitor->print_pos_srcid) { - if (g_source_remove (monitor->print_pos_srcid)) - monitor->print_pos_srcid = 0; - } - - G_OBJECT_CLASS (parent_class)->dispose (object); -} - - -static void gst_validate_pipeline_monitor_class_init (GstValidatePipelineMonitorClass * klass) { - GObjectClass *gobject_class; - - gobject_class = G_OBJECT_CLASS (klass); - - gobject_class->dispose = gst_validate_pipeline_monitor_dispose; } static void @@ -143,6 +123,28 @@ _bus_handler (GstBus * bus, GstMessage * message, g_error_free (err); g_free (debug); break; + case GST_MESSAGE_STATE_CHANGED: + { + if (GST_MESSAGE_SRC (message) == GST_VALIDATE_MONITOR (monitor)->target) { + GstState oldstate, newstate, pending; + + gst_message_parse_state_changed (message, &oldstate, &newstate, + &pending); + + if (oldstate == GST_STATE_READY && newstate == GST_STATE_PAUSED) { + monitor->print_pos_srcid = + g_timeout_add (PRINT_POSITION_TIMEOUT, + (GSourceFunc) print_position, monitor); + } else if (oldstate == GST_STATE_PAUSED && newstate == GST_STATE_READY) { + if (monitor->print_pos_srcid + && g_source_remove (monitor->print_pos_srcid)) + monitor->print_pos_srcid = 0; + + } + } + + break; + } case GST_MESSAGE_BUFFERING: { GstBufferingMode mode; @@ -225,11 +227,6 @@ gst_validate_pipeline_monitor_new (GstPipeline * pipeline, gst_validate_pipeline_monitor_create_scenarios (GST_VALIDATE_BIN_MONITOR (monitor)); - - monitor->print_pos_srcid = - g_timeout_add (PRINT_POSITION_TIMEOUT, (GSourceFunc) print_position, - monitor); - bus = gst_element_get_bus (GST_ELEMENT (pipeline)); gst_bus_enable_sync_message_emission (bus); g_signal_connect (bus, "sync-message", (GCallback) _bus_handler, monitor);