mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 13:06:23 +00:00
check/: fix tests for the new warning
Original commit message from CVS: * check/gst/gstbin.c: * check/states/sinks.c: fix tests for the new warning * check/gst/gstpipeline.c: add a test for pipeline and bus interaction * gst/gstelement.c: elements should be NULL if they get disposed; add a warning if not
This commit is contained in:
parent
91e8b0bb91
commit
18682cacc1
8 changed files with 234 additions and 3 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-09-29 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* check/gst/gstbin.c:
|
||||||
|
* check/states/sinks.c:
|
||||||
|
fix tests for the new warning
|
||||||
|
* check/gst/gstpipeline.c:
|
||||||
|
add a test for pipeline and bus interaction
|
||||||
|
* gst/gstelement.c:
|
||||||
|
elements should be NULL if they get disposed; add a warning if not
|
||||||
|
|
||||||
2005-09-29 Thomas Vander Stichele <thomas at apestaart dot org>
|
2005-09-29 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* gst/gstobject.c:
|
* gst/gstobject.c:
|
||||||
|
|
|
@ -133,6 +133,8 @@ GST_START_TEST (test_message_state_changed)
|
||||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
|
||||||
|
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
gst_object_unref (bin);
|
gst_object_unref (bin);
|
||||||
}
|
}
|
||||||
|
@ -192,6 +194,8 @@ GST_START_TEST (test_message_state_changed_child)
|
||||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL)
|
||||||
|
== GST_STATE_CHANGE_SUCCESS);
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
gst_object_unref (bin);
|
gst_object_unref (bin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ GST_START_TEST (test_async_state_change_fake)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_bus)
|
GST_START_TEST (test_get_bus)
|
||||||
{
|
{
|
||||||
GstPipeline *pipeline;
|
GstPipeline *pipeline;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
@ -129,6 +129,107 @@ GST_START_TEST (test_bus)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GMainLoop *loop = NULL;
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
message_received (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
|
{
|
||||||
|
GstElement *pipeline = GST_ELEMENT (data);
|
||||||
|
GstMessageType type = message->type;
|
||||||
|
|
||||||
|
GST_DEBUG ("message received");
|
||||||
|
switch (type) {
|
||||||
|
case GST_MESSAGE_STATE_CHANGED:
|
||||||
|
{
|
||||||
|
GstState old, new;
|
||||||
|
|
||||||
|
GST_DEBUG ("state change message received");
|
||||||
|
gst_message_parse_state_changed (message, &old, &new);
|
||||||
|
GST_DEBUG ("new state %d", new);
|
||||||
|
if (message->src == GST_OBJECT (pipeline) && new == GST_STATE_PLAYING) {
|
||||||
|
GST_DEBUG ("quitting main loop");
|
||||||
|
g_main_loop_quit (loop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GST_MESSAGE_ERROR:
|
||||||
|
{
|
||||||
|
g_print ("error\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_START_TEST (test_bus)
|
||||||
|
{
|
||||||
|
GstElement *pipeline;
|
||||||
|
GstElement *src, *sink;
|
||||||
|
GstBus *bus;
|
||||||
|
guint id;
|
||||||
|
GstState current;
|
||||||
|
|
||||||
|
pipeline = gst_pipeline_new (NULL);
|
||||||
|
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||||
|
g_object_set (pipeline, "play-timeout", 0LL, NULL);
|
||||||
|
|
||||||
|
src = gst_element_factory_make ("fakesrc", NULL);
|
||||||
|
fail_unless (src != NULL);
|
||||||
|
sink = gst_element_factory_make ("fakesink", NULL);
|
||||||
|
fail_unless (sink != NULL);
|
||||||
|
|
||||||
|
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
|
||||||
|
fail_unless (gst_element_link (src, sink));
|
||||||
|
|
||||||
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after get_bus", 1);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||||
|
|
||||||
|
id = gst_bus_add_watch (bus, message_received, pipeline);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after add_watch", 1);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 3);
|
||||||
|
|
||||||
|
gst_element_set_state_async (pipeline, GST_STATE_PLAYING);
|
||||||
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
GST_DEBUG ("going into main loop");
|
||||||
|
g_main_loop_run (loop);
|
||||||
|
GST_DEBUG ("left main loop");
|
||||||
|
|
||||||
|
/* PLAYING now */
|
||||||
|
|
||||||
|
ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "pipeline after gone to playing", 1,
|
||||||
|
3);
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
GST_DEBUG ("cleanup");
|
||||||
|
|
||||||
|
/* current semantics require us to go step by step; this will change */
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
fail_unless (gst_element_get_state (pipeline, ¤t, NULL, NULL) ==
|
||||||
|
GST_STATE_CHANGE_SUCCESS);
|
||||||
|
fail_unless (current == GST_STATE_NULL, "state is not NULL but %d", current);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3);
|
||||||
|
|
||||||
|
fail_unless (g_source_remove (id));
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2);
|
||||||
|
|
||||||
|
GST_DEBUG ("unreffing pipeline");
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
|
||||||
|
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after unref pipeline", 1);
|
||||||
|
gst_object_unref (bus);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
Suite *
|
Suite *
|
||||||
gst_pipeline_suite (void)
|
gst_pipeline_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -139,6 +240,7 @@ gst_pipeline_suite (void)
|
||||||
tcase_add_test (tc_chain, test_async_state_change_empty);
|
tcase_add_test (tc_chain, test_async_state_change_empty);
|
||||||
tcase_add_test (tc_chain, test_async_state_change_fake_ready);
|
tcase_add_test (tc_chain, test_async_state_change_fake_ready);
|
||||||
tcase_add_test (tc_chain, test_async_state_change_fake);
|
tcase_add_test (tc_chain, test_async_state_change_fake);
|
||||||
|
tcase_add_test (tc_chain, test_get_bus);
|
||||||
tcase_add_test (tc_chain, test_bus);
|
tcase_add_test (tc_chain, test_bus);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
|
@ -51,6 +51,9 @@ GST_START_TEST (test_sink)
|
||||||
ret = gst_element_set_state (sink, GST_STATE_READY);
|
ret = gst_element_set_state (sink, GST_STATE_READY);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to ready");
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to ready");
|
||||||
|
|
||||||
|
ret = gst_element_set_state (sink, GST_STATE_NULL);
|
||||||
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to null");
|
||||||
|
|
||||||
gst_object_unref (sink);
|
gst_object_unref (sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2121,6 +2121,9 @@ gst_element_dispose (GObject * object)
|
||||||
|
|
||||||
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "dispose");
|
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "dispose");
|
||||||
|
|
||||||
|
g_return_if_fail (GST_STATE (element) == GST_STATE_NULL);
|
||||||
|
g_return_if_fail (GST_STATE_PENDING (element) == GST_STATE_VOID_PENDING);
|
||||||
|
|
||||||
/* first we break all our links with the outside */
|
/* first we break all our links with the outside */
|
||||||
while (element->pads) {
|
while (element->pads) {
|
||||||
gst_element_remove_pad (element, GST_PAD_CAST (element->pads->data));
|
gst_element_remove_pad (element, GST_PAD_CAST (element->pads->data));
|
||||||
|
@ -2135,7 +2138,7 @@ gst_element_dispose (GObject * object)
|
||||||
gst_object_replace ((GstObject **) & element->bus, NULL);
|
gst_object_replace ((GstObject **) & element->bus, NULL);
|
||||||
GST_UNLOCK (element);
|
GST_UNLOCK (element);
|
||||||
|
|
||||||
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "dispose parent");
|
GST_CAT_INFO_OBJECT (GST_CAT_REFCOUNTING, element, "parent class dispose");
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,9 @@ GST_START_TEST (test_sink)
|
||||||
ret = gst_element_set_state (sink, GST_STATE_READY);
|
ret = gst_element_set_state (sink, GST_STATE_READY);
|
||||||
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to ready");
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to ready");
|
||||||
|
|
||||||
|
ret = gst_element_set_state (sink, GST_STATE_NULL);
|
||||||
|
fail_unless (ret == GST_STATE_CHANGE_SUCCESS, "failed to go to null");
|
||||||
|
|
||||||
gst_object_unref (sink);
|
gst_object_unref (sink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,6 +133,8 @@ GST_START_TEST (test_message_state_changed)
|
||||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
|
||||||
|
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
gst_object_unref (bin);
|
gst_object_unref (bin);
|
||||||
}
|
}
|
||||||
|
@ -192,6 +194,8 @@ GST_START_TEST (test_message_state_changed_child)
|
||||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
|
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL)
|
||||||
|
== GST_STATE_CHANGE_SUCCESS);
|
||||||
gst_object_unref (bus);
|
gst_object_unref (bus);
|
||||||
gst_object_unref (bin);
|
gst_object_unref (bin);
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ GST_START_TEST (test_async_state_change_fake)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_bus)
|
GST_START_TEST (test_get_bus)
|
||||||
{
|
{
|
||||||
GstPipeline *pipeline;
|
GstPipeline *pipeline;
|
||||||
GstBus *bus;
|
GstBus *bus;
|
||||||
|
@ -129,6 +129,107 @@ GST_START_TEST (test_bus)
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GMainLoop *loop = NULL;
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
message_received (GstBus * bus, GstMessage * message, gpointer data)
|
||||||
|
{
|
||||||
|
GstElement *pipeline = GST_ELEMENT (data);
|
||||||
|
GstMessageType type = message->type;
|
||||||
|
|
||||||
|
GST_DEBUG ("message received");
|
||||||
|
switch (type) {
|
||||||
|
case GST_MESSAGE_STATE_CHANGED:
|
||||||
|
{
|
||||||
|
GstState old, new;
|
||||||
|
|
||||||
|
GST_DEBUG ("state change message received");
|
||||||
|
gst_message_parse_state_changed (message, &old, &new);
|
||||||
|
GST_DEBUG ("new state %d", new);
|
||||||
|
if (message->src == GST_OBJECT (pipeline) && new == GST_STATE_PLAYING) {
|
||||||
|
GST_DEBUG ("quitting main loop");
|
||||||
|
g_main_loop_quit (loop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case GST_MESSAGE_ERROR:
|
||||||
|
{
|
||||||
|
g_print ("error\n");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_START_TEST (test_bus)
|
||||||
|
{
|
||||||
|
GstElement *pipeline;
|
||||||
|
GstElement *src, *sink;
|
||||||
|
GstBus *bus;
|
||||||
|
guint id;
|
||||||
|
GstState current;
|
||||||
|
|
||||||
|
pipeline = gst_pipeline_new (NULL);
|
||||||
|
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||||
|
g_object_set (pipeline, "play-timeout", 0LL, NULL);
|
||||||
|
|
||||||
|
src = gst_element_factory_make ("fakesrc", NULL);
|
||||||
|
fail_unless (src != NULL);
|
||||||
|
sink = gst_element_factory_make ("fakesink", NULL);
|
||||||
|
fail_unless (sink != NULL);
|
||||||
|
|
||||||
|
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
|
||||||
|
fail_unless (gst_element_link (src, sink));
|
||||||
|
|
||||||
|
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after get_bus", 1);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||||
|
|
||||||
|
id = gst_bus_add_watch (bus, message_received, pipeline);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline after add_watch", 1);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after add_watch", 3);
|
||||||
|
|
||||||
|
gst_element_set_state_async (pipeline, GST_STATE_PLAYING);
|
||||||
|
loop = g_main_loop_new (NULL, FALSE);
|
||||||
|
GST_DEBUG ("going into main loop");
|
||||||
|
g_main_loop_run (loop);
|
||||||
|
GST_DEBUG ("left main loop");
|
||||||
|
|
||||||
|
/* PLAYING now */
|
||||||
|
|
||||||
|
ASSERT_OBJECT_REFCOUNT_BETWEEN (pipeline, "pipeline after gone to playing", 1,
|
||||||
|
3);
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
GST_DEBUG ("cleanup");
|
||||||
|
|
||||||
|
/* current semantics require us to go step by step; this will change */
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_PAUSED);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_READY);
|
||||||
|
gst_element_set_state (pipeline, GST_STATE_NULL);
|
||||||
|
fail_unless (gst_element_get_state (pipeline, ¤t, NULL, NULL) ==
|
||||||
|
GST_STATE_CHANGE_SUCCESS);
|
||||||
|
fail_unless (current == GST_STATE_NULL, "state is not NULL but %d", current);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline at start of cleanup", 1);
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus at start of cleanup", 3);
|
||||||
|
|
||||||
|
fail_unless (g_source_remove (id));
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after removing source", 2);
|
||||||
|
|
||||||
|
GST_DEBUG ("unreffing pipeline");
|
||||||
|
gst_object_unref (pipeline);
|
||||||
|
|
||||||
|
|
||||||
|
ASSERT_OBJECT_REFCOUNT (bus, "bus after unref pipeline", 1);
|
||||||
|
gst_object_unref (bus);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
Suite *
|
Suite *
|
||||||
gst_pipeline_suite (void)
|
gst_pipeline_suite (void)
|
||||||
{
|
{
|
||||||
|
@ -139,6 +240,7 @@ gst_pipeline_suite (void)
|
||||||
tcase_add_test (tc_chain, test_async_state_change_empty);
|
tcase_add_test (tc_chain, test_async_state_change_empty);
|
||||||
tcase_add_test (tc_chain, test_async_state_change_fake_ready);
|
tcase_add_test (tc_chain, test_async_state_change_fake_ready);
|
||||||
tcase_add_test (tc_chain, test_async_state_change_fake);
|
tcase_add_test (tc_chain, test_async_state_change_fake);
|
||||||
|
tcase_add_test (tc_chain, test_get_bus);
|
||||||
tcase_add_test (tc_chain, test_bus);
|
tcase_add_test (tc_chain, test_bus);
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|
Loading…
Reference in a new issue