Added extra field to STATE_CHANGE message with the pending state, which will be diffe...
authorWim Taymans <wim.taymans@gmail.com>
Sat, 8 Oct 2005 08:58:45 +0000 (08:58 +0000)
committerWim Taymans <wim.taymans@gmail.com>
Sat, 8 Oct 2005 08:58:45 +0000 (08:58 +0000)
Original commit message from CVS:
* check/gst/gstbin.c: (GST_START_TEST):
* check/gst/gstmessage.c: (GST_START_TEST):
* check/gst/gstpipeline.c: (GST_START_TEST), (message_received):
* gst/gstelement.c: (gst_element_commit_state),
(gst_element_lost_state):
* gst/gstmessage.c: (gst_message_new_state_changed),
(gst_message_parse_state_changed):
* gst/gstmessage.h:
* tools/gst-launch.c: (event_loop):
Added extra field to STATE_CHANGE message with the pending
state, which will be different from the new state soon.

ChangeLog
check/gst/gstbin.c
check/gst/gstmessage.c
check/gst/gstpipeline.c
gst/gstelement.c
gst/gstmessage.c
gst/gstmessage.h
tests/check/gst/gstbin.c
tests/check/gst/gstmessage.c
tests/check/gst/gstpipeline.c
tools/gst-launch.c

index 53b6a11cdb700d67e48e339b1ff9528c7000f652..366f02379eef3ea7324fd270b4e739bf98f3f00b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2005-10-08  Wim Taymans  <wim@fluendo.com>
+
+       * check/gst/gstbin.c: (GST_START_TEST):
+       * check/gst/gstmessage.c: (GST_START_TEST):
+       * check/gst/gstpipeline.c: (GST_START_TEST), (message_received):
+       * gst/gstelement.c: (gst_element_commit_state),
+       (gst_element_lost_state):
+       * gst/gstmessage.c: (gst_message_new_state_changed),
+       (gst_message_parse_state_changed):
+       * gst/gstmessage.h:
+       * tools/gst-launch.c: (event_loop):
+       Added extra field to STATE_CHANGE message with the pending
+       state, which will be different from the new state soon.
+
 2005-10-08  Wim Taymans  <wim@fluendo.com>
 
        * gst/gstbus.c: (gst_bus_pop):
index 4d6c7f883238273c20386a74ebba10ca0a9acc66..020e9143a7efddaf6f5580541f5c229804838f02 100644 (file)
@@ -448,11 +448,11 @@ GST_END_TEST;
 #define ASSERT_STATE_CHANGE_MSG(bus,element,old_state,new_state,num)          \
   {                                                                           \
     GstMessage *msg;                                                          \
-    GstState old = 0, new = 0;                                                \
+    GstState old = 0, new = 0, pending = 0;                                   \
     msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND);          \
     fail_if (msg == NULL, "No state change message within 1 second (#"        \
         G_STRINGIFY (num) ")");                                               \
-    gst_message_parse_state_changed (msg, &old, &new);                        \
+    gst_message_parse_state_changed (msg, &old, &new, &pending);              \
     fail_if (msg->src != GST_OBJECT (element), G_STRINGIFY(element)           \
         " should have changed state next (#" G_STRINGIFY (num) ")");          \
     fail_if (old != old_state || new != new_state, "state change is not "     \
@@ -681,13 +681,13 @@ GST_START_TEST (test_children_state_change_order_two_sink)
   /* NULL => READY */
   {
     GstMessage *msg;
-    GstState old = 0, new = 0;
+    GstState old = 0, new = 0, pending = 0;
     GstObject *first, *second;
 
     msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND);
     fail_if (msg == NULL, "No state change message within 1 second (#201)");
 
-    gst_message_parse_state_changed (msg, &old, &new);
+    gst_message_parse_state_changed (msg, &old, &new, &pending);
     first = gst_object_ref (msg->src);
 
     fail_if (first != GST_OBJECT (sink1) && first != GST_OBJECT (sink2),
@@ -697,7 +697,7 @@ GST_START_TEST (test_children_state_change_order_two_sink)
     msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND);
     fail_if (msg == NULL, "No state change message within 1 second (#201)");
 
-    gst_message_parse_state_changed (msg, &old, &new);
+    gst_message_parse_state_changed (msg, &old, &new, &pending);
     second = gst_object_ref (msg->src);
 
     fail_if (second != GST_OBJECT (sink1) && second != GST_OBJECT (sink2),
index cf0216fe41c1ed0b9f05cf52506c784d07672db4..a96711340e72fb2a2595e17860a73bce09305c20 100644 (file)
@@ -120,21 +120,26 @@ GST_START_TEST (test_parsing)
   }
   /* GST_MESSAGE_STATE_CHANGED   */
   {
-    GstState oldstate, newstate;
+    GstState oldstate, newstate, pending;
 
     oldstate = GST_STATE_PAUSED;
     newstate = GST_STATE_PLAYING;
+    pending = GST_STATE_VOID_PENDING;
 
-    message = gst_message_new_state_changed (NULL, oldstate, newstate);
+    message = gst_message_new_state_changed (NULL, oldstate, newstate, pending);
     fail_if (message == NULL);
     fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
     fail_unless (GST_MESSAGE_SRC (message) == NULL);
 
+    /* set some wrong values to check if the parse method overwrites them
+     * with the good values */
     oldstate = GST_STATE_READY;
     newstate = GST_STATE_READY;
-    gst_message_parse_state_changed (message, &oldstate, &newstate);
+    pending = GST_STATE_READY;
+    gst_message_parse_state_changed (message, &oldstate, &newstate, &pending);
     fail_unless (oldstate == GST_STATE_PAUSED);
     fail_unless (newstate == GST_STATE_PLAYING);
+    fail_unless (pending == GST_STATE_VOID_PENDING);
 
     gst_message_unref (message);
   }
index dbafeeeb8a1e2da258179a0a9e7802b945a3d27c..e516789869bb5d042213aa52c5ce35302b11a2f9 100644 (file)
@@ -86,11 +86,11 @@ GST_START_TEST (test_async_state_change_fake)
 
   while (!done) {
     GstMessage *message;
-    GstState old, new;
+    GstState old, new, pending;
 
     message = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, -1);
     if (message) {
-      gst_message_parse_state_changed (message, &old, &new);
+      gst_message_parse_state_changed (message, &old, &new, &pending);
       GST_DEBUG_OBJECT (message->src, "state change from %d to %d", old, new);
       if (message->src == GST_OBJECT (pipeline) && new == GST_STATE_PLAYING)
         done = TRUE;
@@ -141,10 +141,10 @@ message_received (GstBus * bus, GstMessage * message, gpointer data)
   switch (type) {
     case GST_MESSAGE_STATE_CHANGED:
     {
-      GstState old, new;
+      GstState old, new, pending;
 
       GST_DEBUG ("state change message received");
-      gst_message_parse_state_changed (message, &old, &new);
+      gst_message_parse_state_changed (message, &old, &new, &pending);
       GST_DEBUG ("new state %d", new);
       if (message->src == GST_OBJECT (pipeline) && new == GST_STATE_PLAYING) {
         GST_DEBUG ("quitting main loop");
index 237f7288f9fceb06b75f534b27d924ad67fee4b7..e43910181581bd4404224f46bbe578322e29bd89 100644 (file)
@@ -1770,7 +1770,7 @@ gst_element_commit_state (GstElement * element)
     GST_STATE_ERROR (element) = FALSE;
 
     message = gst_message_new_state_changed (GST_OBJECT (element),
-        old_state, pending);
+        old_state, pending, pending);
     gst_element_post_message (element, message);
     GST_STATE_BROADCAST (element);
   }
@@ -1810,7 +1810,7 @@ gst_element_lost_state (GstElement * element)
     GST_STATE_ERROR (element) = FALSE;
 
     message = gst_message_new_state_changed (GST_OBJECT (element),
-        current_state, current_state);
+        current_state, current_state, current_state);
     gst_element_post_message (element, message);
   }
 }
index 6448292a424ab16e83405ed4a8ccaf7021b73471..41d1b7c75a037e4f897674782c638902c43ba9e4 100644 (file)
@@ -354,6 +354,7 @@ gst_message_new_tag (GstObject * src, GstTagList * tag_list)
  * @src: The object originating the message.
  * @old: The previous state.
  * @new: The new (current) state.
+ * @pending: The pending (target) state.
  *
  * Create a state change message. This message is posted whenever an element changed
  * its state.
@@ -363,15 +364,18 @@ gst_message_new_tag (GstObject * src, GstTagList * tag_list)
  * MT safe.
  */
 GstMessage *
-gst_message_new_state_changed (GstObject * src, GstState old, GstState new)
+gst_message_new_state_changed (GstObject * src,
+    GstState old, GstState new, GstState pending)
 {
   GstMessage *message;
   GstStructure *s;
 
   message = gst_message_new (GST_MESSAGE_STATE_CHANGED, src);
 
-  s = gst_structure_new ("GstMessageState", "old-state", GST_TYPE_STATE,
-      (gint) old, "new-state", GST_TYPE_STATE, (gint) new, NULL);
+  s = gst_structure_new ("GstMessageState",
+      "old-state", GST_TYPE_STATE, (gint) old,
+      "new-state", GST_TYPE_STATE, (gint) new,
+      "pending-state", GST_TYPE_STATE, (gint) pending, NULL);
   gst_structure_set_parent_refcount (s, &message->mini_object.refcount);
   message->structure = s;
 
@@ -545,6 +549,9 @@ gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
 /**
  * gst_message_parse_state_changed:
  * @message: A valid #GstMessage of type GST_MESSAGE_STATE_CHANGED.
+ * @old: The previous state.
+ * @new: The new (current) state.
+ * @pending: The pending (target) state.
  *
  * Extracts the old and new states from the GstMessage.
  *
@@ -552,17 +559,20 @@ gst_message_parse_tag (GstMessage * message, GstTagList ** tag_list)
  */
 void
 gst_message_parse_state_changed (GstMessage * message, GstState * old,
-    GstState * new)
+    GstState * new, GstState * pending)
 {
   g_return_if_fail (GST_IS_MESSAGE (message));
   g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
 
-  if (!gst_structure_get_enum (message->structure, "old-state",
-          GST_TYPE_STATE, (gint *) old))
-    g_assert_not_reached ();
-  if (!gst_structure_get_enum (message->structure, "new-state",
-          GST_TYPE_STATE, (gint *) new))
-    g_assert_not_reached ();
+  if (old)
+    gst_structure_get_enum (message->structure, "old-state",
+        GST_TYPE_STATE, (gint *) old);
+  if (new)
+    gst_structure_get_enum (message->structure, "new-state",
+        GST_TYPE_STATE, (gint *) new);
+  if (pending)
+    gst_structure_get_enum (message->structure, "pending-state",
+        GST_TYPE_STATE, (gint *) pending);
 }
 
 /**
index f2be6a9ecf9113612c94b12b001fc23842d25245..313863873135949f54c7734d769ad51e0b2d4466 100644 (file)
@@ -145,7 +145,7 @@ GstMessage *        gst_message_new_error           (GstObject * src, GError * error, gchar * d
 GstMessage *   gst_message_new_warning         (GstObject * src, GError * error, gchar * debug);
 GstMessage *   gst_message_new_tag             (GstObject * src, GstTagList * tag_list);
 GstMessage *   gst_message_new_state_changed   (GstObject * src, GstState old_state,
-                                                 GstState new_state);
+                                                 GstState new_state, GstState pending);
 GstMessage *   gst_message_new_segment_start   (GstObject * src, GstClockTime timestamp);
 GstMessage *   gst_message_new_segment_done    (GstObject * src, GstClockTime timestamp);
 GstMessage *   gst_message_new_application     (GstObject * src, GstStructure * structure);
@@ -158,7 +158,7 @@ void                gst_message_parse_error         (GstMessage *message, GError **gerror, gchar **de
 void           gst_message_parse_warning       (GstMessage *message, GError **gerror, gchar **debug);
 void           gst_message_parse_tag           (GstMessage *message, GstTagList **tag_list);
 void           gst_message_parse_state_changed (GstMessage *message, GstState *old_state,
-                                                 GstState *new_state);
+                                                 GstState *new_state, GstState *pending);
 void           gst_message_parse_segment_start (GstMessage *message, GstClockTime *timestamp);
 void           gst_message_parse_segment_done  (GstMessage *message, GstClockTime *timestamp);
 
index 4d6c7f883238273c20386a74ebba10ca0a9acc66..020e9143a7efddaf6f5580541f5c229804838f02 100644 (file)
@@ -448,11 +448,11 @@ GST_END_TEST;
 #define ASSERT_STATE_CHANGE_MSG(bus,element,old_state,new_state,num)          \
   {                                                                           \
     GstMessage *msg;                                                          \
-    GstState old = 0, new = 0;                                                \
+    GstState old = 0, new = 0, pending = 0;                                   \
     msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND);          \
     fail_if (msg == NULL, "No state change message within 1 second (#"        \
         G_STRINGIFY (num) ")");                                               \
-    gst_message_parse_state_changed (msg, &old, &new);                        \
+    gst_message_parse_state_changed (msg, &old, &new, &pending);              \
     fail_if (msg->src != GST_OBJECT (element), G_STRINGIFY(element)           \
         " should have changed state next (#" G_STRINGIFY (num) ")");          \
     fail_if (old != old_state || new != new_state, "state change is not "     \
@@ -681,13 +681,13 @@ GST_START_TEST (test_children_state_change_order_two_sink)
   /* NULL => READY */
   {
     GstMessage *msg;
-    GstState old = 0, new = 0;
+    GstState old = 0, new = 0, pending = 0;
     GstObject *first, *second;
 
     msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND);
     fail_if (msg == NULL, "No state change message within 1 second (#201)");
 
-    gst_message_parse_state_changed (msg, &old, &new);
+    gst_message_parse_state_changed (msg, &old, &new, &pending);
     first = gst_object_ref (msg->src);
 
     fail_if (first != GST_OBJECT (sink1) && first != GST_OBJECT (sink2),
@@ -697,7 +697,7 @@ GST_START_TEST (test_children_state_change_order_two_sink)
     msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, GST_SECOND);
     fail_if (msg == NULL, "No state change message within 1 second (#201)");
 
-    gst_message_parse_state_changed (msg, &old, &new);
+    gst_message_parse_state_changed (msg, &old, &new, &pending);
     second = gst_object_ref (msg->src);
 
     fail_if (second != GST_OBJECT (sink1) && second != GST_OBJECT (sink2),
index cf0216fe41c1ed0b9f05cf52506c784d07672db4..a96711340e72fb2a2595e17860a73bce09305c20 100644 (file)
@@ -120,21 +120,26 @@ GST_START_TEST (test_parsing)
   }
   /* GST_MESSAGE_STATE_CHANGED   */
   {
-    GstState oldstate, newstate;
+    GstState oldstate, newstate, pending;
 
     oldstate = GST_STATE_PAUSED;
     newstate = GST_STATE_PLAYING;
+    pending = GST_STATE_VOID_PENDING;
 
-    message = gst_message_new_state_changed (NULL, oldstate, newstate);
+    message = gst_message_new_state_changed (NULL, oldstate, newstate, pending);
     fail_if (message == NULL);
     fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_STATE_CHANGED);
     fail_unless (GST_MESSAGE_SRC (message) == NULL);
 
+    /* set some wrong values to check if the parse method overwrites them
+     * with the good values */
     oldstate = GST_STATE_READY;
     newstate = GST_STATE_READY;
-    gst_message_parse_state_changed (message, &oldstate, &newstate);
+    pending = GST_STATE_READY;
+    gst_message_parse_state_changed (message, &oldstate, &newstate, &pending);
     fail_unless (oldstate == GST_STATE_PAUSED);
     fail_unless (newstate == GST_STATE_PLAYING);
+    fail_unless (pending == GST_STATE_VOID_PENDING);
 
     gst_message_unref (message);
   }
index dbafeeeb8a1e2da258179a0a9e7802b945a3d27c..e516789869bb5d042213aa52c5ce35302b11a2f9 100644 (file)
@@ -86,11 +86,11 @@ GST_START_TEST (test_async_state_change_fake)
 
   while (!done) {
     GstMessage *message;
-    GstState old, new;
+    GstState old, new, pending;
 
     message = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, -1);
     if (message) {
-      gst_message_parse_state_changed (message, &old, &new);
+      gst_message_parse_state_changed (message, &old, &new, &pending);
       GST_DEBUG_OBJECT (message->src, "state change from %d to %d", old, new);
       if (message->src == GST_OBJECT (pipeline) && new == GST_STATE_PLAYING)
         done = TRUE;
@@ -141,10 +141,10 @@ message_received (GstBus * bus, GstMessage * message, gpointer data)
   switch (type) {
     case GST_MESSAGE_STATE_CHANGED:
     {
-      GstState old, new;
+      GstState old, new, pending;
 
       GST_DEBUG ("state change message received");
-      gst_message_parse_state_changed (message, &old, &new);
+      gst_message_parse_state_changed (message, &old, &new, &pending);
       GST_DEBUG ("new state %d", new);
       if (message->src == GST_OBJECT (pipeline) && new == GST_STATE_PLAYING) {
         GST_DEBUG ("quitting main loop");
index 38239e317a8eb0a01bc1efa5270140faa914f17c..301351f532830300412d95c9d24e05d944b29987 100644 (file)
@@ -438,9 +438,9 @@ event_loop (GstElement * pipeline, gboolean blocking)
         return TRUE;
       }
       case GST_MESSAGE_STATE_CHANGED:{
-        GstState old, new;
+        GstState old, new, pending;
 
-        gst_message_parse_state_changed (message, &old, &new);
+        gst_message_parse_state_changed (message, &old, &new, &pending);
         if (!(old == GST_STATE_PLAYING && new == GST_STATE_PAUSED &&
                 GST_MESSAGE_SRC (message) == GST_OBJECT (pipeline))) {
           gst_message_unref (message);