summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@gmail.com>2005-10-08 08:58:45 +0000
committerWim Taymans <wim.taymans@gmail.com>2005-10-08 08:58:45 +0000
commitce081d6341c7bbc1d49bf574918f8a4dd4dd20ab (patch)
tree0b182799b37889f5cfe514f2fa5b6382b4321c82
parent8e213e710b9582ba03a2126740e03bf49016b967 (diff)
Added extra field to STATE_CHANGE message with the pending state, which will be different from the new state soon.
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.
-rw-r--r--ChangeLog14
-rw-r--r--check/gst/gstbin.c10
-rw-r--r--check/gst/gstmessage.c11
-rw-r--r--check/gst/gstpipeline.c8
-rw-r--r--gst/gstelement.c4
-rw-r--r--gst/gstmessage.c30
-rw-r--r--gst/gstmessage.h4
-rw-r--r--tests/check/gst/gstbin.c10
-rw-r--r--tests/check/gst/gstmessage.c11
-rw-r--r--tests/check/gst/gstpipeline.c8
-rw-r--r--tools/gst-launch.c4
11 files changed, 74 insertions, 40 deletions
diff --git a/ChangeLog b/ChangeLog
index 53b6a11cd..366f02379 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
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):
* gst/gstclock.c:
* gst/gstsystemclock.c: (gst_system_clock_async_thread):
diff --git a/check/gst/gstbin.c b/check/gst/gstbin.c
index 4d6c7f883..020e9143a 100644
--- a/check/gst/gstbin.c
+++ b/check/gst/gstbin.c
@@ -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),
diff --git a/check/gst/gstmessage.c b/check/gst/gstmessage.c
index cf0216fe4..a96711340 100644
--- a/check/gst/gstmessage.c
+++ b/check/gst/gstmessage.c
@@ -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);
}
diff --git a/check/gst/gstpipeline.c b/check/gst/gstpipeline.c
index dbafeeeb8..e51678986 100644
--- a/check/gst/gstpipeline.c
+++ b/check/gst/gstpipeline.c
@@ -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");
diff --git a/gst/gstelement.c b/gst/gstelement.c
index 237f7288f..e43910181 100644
--- a/gst/gstelement.c
+++ b/gst/gstelement.c
@@ -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);
}
}
diff --git a/gst/gstmessage.c b/gst/gstmessage.c
index 6448292a4..41d1b7c75 100644
--- a/gst/gstmessage.c
+++ b/gst/gstmessage.c
@@ -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);
}
/**
diff --git a/gst/gstmessage.h b/gst/gstmessage.h
index f2be6a9ec..313863873 100644
--- a/gst/gstmessage.h
+++ b/gst/gstmessage.h
@@ -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);
diff --git a/tests/check/gst/gstbin.c b/tests/check/gst/gstbin.c
index 4d6c7f883..020e9143a 100644
--- a/tests/check/gst/gstbin.c
+++ b/tests/check/gst/gstbin.c
@@ -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),
diff --git a/tests/check/gst/gstmessage.c b/tests/check/gst/gstmessage.c
index cf0216fe4..a96711340 100644
--- a/tests/check/gst/gstmessage.c
+++ b/tests/check/gst/gstmessage.c
@@ -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);
}
diff --git a/tests/check/gst/gstpipeline.c b/tests/check/gst/gstpipeline.c
index dbafeeeb8..e51678986 100644
--- a/tests/check/gst/gstpipeline.c
+++ b/tests/check/gst/gstpipeline.c
@@ -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");
diff --git a/tools/gst-launch.c b/tools/gst-launch.c
index 38239e317..301351f53 100644
--- a/tools/gst-launch.c
+++ b/tools/gst-launch.c
@@ -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);