mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-10 17:35:59 +00:00
check/gst/gstbin.c: Add bus to bin.
Original commit message from CVS: * check/gst/gstbin.c: (GST_START_TEST): Add bus to bin. * gst/gstbin.c: (gst_bin_class_init), (gst_bin_init), (add_to_queue), (clear_queue), (reset_degree), (update_degree), (find_element), (gst_bin_sort_iterator_next), (gst_bin_sort_iterator_resync), (gst_bin_sort_iterator_free), (gst_bin_iterate_sorted), (gst_bin_element_set_state), (gst_bin_change_state), (gst_bin_dispose): A bin does not have a bus, it gets the bus from the parent. * gst/gstelement.c: (gst_element_requires_clock), (gst_element_provides_clock), (gst_element_is_indexable), (gst_element_is_locked_state), (gst_element_change_state), (gst_element_set_bus_func): Small cleanups. * gst/gstpipeline.c: (gst_pipeline_class_init), (gst_pipeline_init), (gst_pipeline_provide_clock_func): The pipeline provides a bus.
This commit is contained in:
parent
d52d4b4a4d
commit
92836e5172
6 changed files with 115 additions and 68 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
|||
2005-09-29 Wim Taymans <wim@fluendo.com>
|
||||
|
||||
* check/gst/gstbin.c: (GST_START_TEST):
|
||||
Add bus to bin.
|
||||
|
||||
* gst/gstbin.c: (gst_bin_class_init), (gst_bin_init),
|
||||
(add_to_queue), (clear_queue), (reset_degree), (update_degree),
|
||||
(find_element), (gst_bin_sort_iterator_next),
|
||||
(gst_bin_sort_iterator_resync), (gst_bin_sort_iterator_free),
|
||||
(gst_bin_iterate_sorted), (gst_bin_element_set_state),
|
||||
(gst_bin_change_state), (gst_bin_dispose):
|
||||
A bin does not have a bus, it gets the bus from the parent.
|
||||
|
||||
* gst/gstelement.c: (gst_element_requires_clock),
|
||||
(gst_element_provides_clock), (gst_element_is_indexable),
|
||||
(gst_element_is_locked_state), (gst_element_change_state),
|
||||
(gst_element_set_bus_func):
|
||||
Small cleanups.
|
||||
|
||||
* gst/gstpipeline.c: (gst_pipeline_class_init),
|
||||
(gst_pipeline_init), (gst_pipeline_provide_clock_func):
|
||||
The pipeline provides a bus.
|
||||
|
||||
2005-09-28 Johan Dahlin <johan@gnome.org>
|
||||
|
||||
* gst/gstmessage.c (gst_message_parse_state_changed): Use
|
||||
|
|
|
@ -114,7 +114,8 @@ GST_START_TEST (test_message_state_changed)
|
|||
fail_unless (bin != NULL, "Could not create bin");
|
||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
bus = GST_ELEMENT_BUS (bin);
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT_CAST (bin), bus);
|
||||
|
||||
/* change state, spawning a message, causing an incref on the bin */
|
||||
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
|
||||
|
@ -132,6 +133,7 @@ GST_START_TEST (test_message_state_changed)
|
|||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (bin);
|
||||
}
|
||||
|
||||
|
@ -148,14 +150,15 @@ GST_START_TEST (test_message_state_changed_child)
|
|||
fail_unless (bin != NULL, "Could not create bin");
|
||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT_CAST (bin), bus);
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
fail_if (src == NULL, "Could not create fakesrc");
|
||||
gst_bin_add (bin, src);
|
||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
|
||||
bus = GST_ELEMENT_BUS (bin);
|
||||
|
||||
/* change state, spawning two messages:
|
||||
* - first for fakesrc, forwarded to bin's bus, causing incref on fakesrc
|
||||
* - second for bin, causing an incref on the bin */
|
||||
|
@ -189,6 +192,7 @@ GST_START_TEST (test_message_state_changed_child)
|
|||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (bin);
|
||||
}
|
||||
|
||||
|
@ -224,7 +228,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_pipeline_get_bus (pipeline);
|
||||
|
||||
/* change state to READY, spawning three messages */
|
||||
GST_DEBUG ("setting pipeline to READY");
|
||||
|
@ -232,7 +236,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
== GST_STATE_CHANGE_SUCCESS);
|
||||
|
||||
/* each object is referenced by a message */
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 2);
|
||||
|
@ -240,7 +244,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
pop_messages (bus, 3);
|
||||
fail_if ((gst_bus_pop (bus)) != NULL);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
@ -260,7 +264,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
pop_messages (bus, 3);
|
||||
fail_if ((gst_bus_pop (bus)) != NULL);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
@ -279,7 +283,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
pop_messages (bus, 3);
|
||||
fail_if ((gst_bus_pop (bus)) != NULL);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
/* sink might have an extra reference if it's still blocked on preroll */
|
||||
ASSERT_OBJECT_REFCOUNT_BETWEEN (sink, "sink", 1, 2);
|
||||
|
@ -311,6 +315,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
@ -324,6 +329,9 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
bin = gst_element_factory_make ("bin", NULL);
|
||||
fail_unless (bin != NULL, "Could not create bin");
|
||||
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT_CAST (bin), bus);
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
fail_if (src == NULL, "Could not create fakesrc");
|
||||
sink = gst_element_factory_make ("fakesink", NULL);
|
||||
|
@ -334,15 +342,13 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
|
||||
fail_unless (gst_element_link (src, sink), "could not link src and sink");
|
||||
|
||||
bus = GST_ELEMENT_BUS (bin);
|
||||
|
||||
/* change state, spawning two times three messages, minus one async */
|
||||
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED)
|
||||
== GST_STATE_CHANGE_ASYNC);
|
||||
|
||||
pop_messages (bus, 5);
|
||||
|
||||
fail_unless (gst_bus_have_pending (bus, GST_MESSAGE_ANY) == FALSE,
|
||||
fail_unless (gst_bus_have_pending (bus) == FALSE,
|
||||
"Unexpected messages on bus");
|
||||
|
||||
gst_bin_watch_for_state_change (GST_BIN (bin));
|
||||
|
@ -350,7 +356,7 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
/* should get the bin's state change message now */
|
||||
pop_messages (bus, 1);
|
||||
|
||||
fail_unless (gst_bus_have_pending (bus, GST_MESSAGE_ANY) == FALSE,
|
||||
fail_unless (gst_bus_have_pending (bus) == FALSE,
|
||||
"Unexpected messages on bus");
|
||||
|
||||
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING)
|
||||
|
@ -365,7 +371,7 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
|
||||
pop_messages (bus, 3);
|
||||
|
||||
fail_unless (gst_bus_have_pending (bus, GST_MESSAGE_ANY) == FALSE,
|
||||
fail_unless (gst_bus_have_pending (bus) == FALSE,
|
||||
"Unexpected messages on bus");
|
||||
|
||||
/* setting bin to NULL flushes the bus automatically */
|
||||
|
@ -373,6 +379,7 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
== GST_STATE_CHANGE_SUCCESS);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (bin);
|
||||
}
|
||||
|
||||
|
@ -458,7 +465,7 @@ GST_START_TEST (test_children_state_change_order_flagged_sink)
|
|||
pipeline = gst_pipeline_new (NULL);
|
||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
fail_unless (bus != NULL, "Pipeline has no bus?!");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
|
@ -531,6 +538,7 @@ GST_START_TEST (test_children_state_change_order_flagged_sink)
|
|||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
@ -548,7 +556,7 @@ GST_START_TEST (test_children_state_change_order_semi_sink)
|
|||
pipeline = gst_pipeline_new (NULL);
|
||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
fail_unless (bus != NULL, "Pipeline has no bus?!");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
|
@ -623,6 +631,7 @@ GST_START_TEST (test_children_state_change_order_semi_sink)
|
|||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
@ -637,7 +646,7 @@ GST_START_TEST (test_children_state_change_order_two_sink)
|
|||
pipeline = gst_pipeline_new (NULL);
|
||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
fail_unless (bus != NULL, "Pipeline has no bus?!");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
|
@ -718,6 +727,7 @@ GST_START_TEST (test_children_state_change_order_two_sink)
|
|||
ASSERT_OBJECT_REFCOUNT (sink2, "sink2", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
|
|
@ -273,16 +273,10 @@ gst_bin_init (GstBin * bin)
|
|||
bin->children_cookie = 0;
|
||||
bin->eosed = NULL;
|
||||
|
||||
/* Set up a bus for listening to child elements,
|
||||
* and one for sending messages up the hierarchy */
|
||||
/* Set up a bus for listening to child elements */
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
bin->child_bus = bus;
|
||||
gst_bus_set_sync_handler (bus, (GstBusSyncHandler) bin_bus_handler, bin);
|
||||
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT (bin), bus);
|
||||
/* set_bus refs the bus via gst_object_replace, we drop our ref */
|
||||
gst_object_unref (bus);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1466,7 +1460,6 @@ gst_bin_dispose (GObject * object)
|
|||
bin->eosed = NULL;
|
||||
gst_object_unref (bin->child_bus);
|
||||
bin->child_bus = NULL;
|
||||
gst_element_set_bus (GST_ELEMENT (bin), NULL);
|
||||
|
||||
while (bin->children) {
|
||||
gst_bin_remove (bin, GST_ELEMENT (bin->children->data));
|
||||
|
|
|
@ -30,8 +30,8 @@
|
|||
*
|
||||
* The name of a GstElement can be get with gst_element_get_name() and set with
|
||||
* gst_element_set_name(). For speed, GST_ELEMENT_NAME() can be used in the
|
||||
* core. Do not use this in plug-ins or applications in order to retain ABI
|
||||
* compatibility.
|
||||
* core when using the appropriate locking. Do not use this in plug-ins or
|
||||
* applications in order to retain ABI compatibility.
|
||||
*
|
||||
* All elements have pads (of the type #GstPad). These pads link to pads on
|
||||
* other elements. Buffers flow between these linked pads.
|
||||
|
@ -308,9 +308,9 @@ gst_element_release_request_pad (GstElement * element, GstPad * pad)
|
|||
gboolean
|
||||
gst_element_requires_clock (GstElement * element)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), result);
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
|
||||
result = (GST_ELEMENT_GET_CLASS (element)->set_clock != NULL);
|
||||
|
||||
|
@ -330,7 +330,7 @@ gst_element_requires_clock (GstElement * element)
|
|||
gboolean
|
||||
gst_element_provides_clock (GstElement * element)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
|
||||
|
@ -346,7 +346,7 @@ gst_element_provides_clock (GstElement * element)
|
|||
* Get the clock provided by the given element.
|
||||
*
|
||||
* Returns: the GstClock provided by the element or NULL
|
||||
* if no clock could be provided.
|
||||
* if no clock could be provided. Unref after usage.
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
|
@ -479,9 +479,9 @@ gst_element_get_base_time (GstElement * element)
|
|||
gboolean
|
||||
gst_element_is_indexable (GstElement * element)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), result);
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
|
||||
result = (GST_ELEMENT_GET_CLASS (element)->set_index != NULL);
|
||||
|
||||
|
@ -493,7 +493,8 @@ gst_element_is_indexable (GstElement * element)
|
|||
* @element: a #GstElement.
|
||||
* @index: a #GstIndex.
|
||||
*
|
||||
* Set the specified GstIndex on the element.
|
||||
* Set the specified GstIndex on the element. The refcount of the index
|
||||
* will be increased, any previously set index is unreffed.
|
||||
*
|
||||
* MT safe.
|
||||
*/
|
||||
|
@ -547,7 +548,8 @@ gst_element_get_index (GstElement * element)
|
|||
* see gst_object_set_parent() for refcounting information.
|
||||
*
|
||||
* Pads are not automatically activated so elements should perform the needed
|
||||
* steps to activate the pad.
|
||||
* steps to activate the pad in case this pad is added in the PAUSED or PLAYING
|
||||
* state.
|
||||
*
|
||||
* The pad and the element should be unlocked when calling this function.
|
||||
*
|
||||
|
@ -912,7 +914,7 @@ gst_element_get_pad (GstElement * element, const gchar * name)
|
|||
return pad;
|
||||
}
|
||||
|
||||
GstIteratorItem
|
||||
static GstIteratorItem
|
||||
iterate_pad (GstIterator * it, GstPad * pad)
|
||||
{
|
||||
gst_object_ref (pad);
|
||||
|
@ -923,7 +925,8 @@ iterate_pad (GstIterator * it, GstPad * pad)
|
|||
* gst_element_iterate_pads:
|
||||
* @element: a #GstElement to iterate pads of.
|
||||
*
|
||||
* Retrieves an iterattor of @element's pads.
|
||||
* Retrieves an iterattor of @element's pads. The iterator should
|
||||
* be freed after usage.
|
||||
*
|
||||
* Returns: the #GstIterator of #GstPad. Unref each pad after use.
|
||||
*
|
||||
|
@ -1488,7 +1491,7 @@ void gst_element_message_full
|
|||
gboolean
|
||||
gst_element_is_locked_state (GstElement * element)
|
||||
{
|
||||
gboolean result = FALSE;
|
||||
gboolean result;
|
||||
|
||||
g_return_val_if_fail (GST_IS_ELEMENT (element), FALSE);
|
||||
|
||||
|
@ -2038,15 +2041,8 @@ gst_element_change_state (GstElement * element, GstStateChange transition)
|
|||
pending = GST_STATE_PENDING (element);
|
||||
|
||||
/* if the element already is in the given state, we just return success */
|
||||
if (pending == GST_STATE_VOID_PENDING || state == GST_STATE_PENDING (element)) {
|
||||
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
|
||||
"element is already in the %s state",
|
||||
gst_element_state_get_name (state));
|
||||
if (GST_STATE_NO_PREROLL (element))
|
||||
return GST_STATE_CHANGE_NO_PREROLL;
|
||||
else
|
||||
return GST_STATE_CHANGE_SUCCESS;
|
||||
}
|
||||
if (pending == GST_STATE_VOID_PENDING || state == GST_STATE_PENDING (element))
|
||||
goto was_ok;
|
||||
|
||||
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element,
|
||||
"default handler tries setting state from %s to %s (%04x)",
|
||||
|
@ -2072,9 +2068,7 @@ gst_element_change_state (GstElement * element, GstStateChange transition)
|
|||
if (!gst_element_pads_activate (element, FALSE)) {
|
||||
result = GST_STATE_CHANGE_FAILURE;
|
||||
} else {
|
||||
GST_LOCK (element);
|
||||
element->base_time = 0;
|
||||
GST_UNLOCK (element);
|
||||
gst_element_set_base_time (element, 0);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -2088,8 +2082,19 @@ gst_element_change_state (GstElement * element, GstStateChange transition)
|
|||
gst_element_state_get_name (pending));
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
was_ok:
|
||||
{
|
||||
GST_CAT_DEBUG_OBJECT (GST_CAT_STATES, element,
|
||||
"element is already in the %s state",
|
||||
gst_element_state_get_name (state));
|
||||
if (GST_STATE_NO_PREROLL (element))
|
||||
return GST_STATE_CHANGE_NO_PREROLL;
|
||||
else
|
||||
return GST_STATE_CHANGE_SUCCESS;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2099,6 +2104,7 @@ gst_element_change_state (GstElement * element, GstStateChange transition)
|
|||
* Retrieves the factory that was used to create this element.
|
||||
*
|
||||
* Returns: the #GstElementFactory used for creating this element.
|
||||
* no refcounting is needed.
|
||||
*/
|
||||
GstElementFactory *
|
||||
gst_element_get_factory (GstElement * element)
|
||||
|
@ -2298,7 +2304,7 @@ gst_element_set_bus_func (GstElement * element, GstBus * bus)
|
|||
|
||||
GST_LOCK (element);
|
||||
gst_object_replace ((GstObject **) & GST_ELEMENT_BUS (element),
|
||||
GST_OBJECT (bus));
|
||||
GST_OBJECT_CAST (bus));
|
||||
GST_UNLOCK (element);
|
||||
}
|
||||
|
||||
|
|
|
@ -153,9 +153,14 @@ static void
|
|||
gst_pipeline_init (GTypeInstance * instance, gpointer g_class)
|
||||
{
|
||||
GstPipeline *pipeline = GST_PIPELINE (instance);
|
||||
GstBus *bus;
|
||||
|
||||
pipeline->delay = DEFAULT_DELAY;
|
||||
pipeline->play_timeout = DEFAULT_PLAY_TIMEOUT;
|
||||
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT_CAST (pipeline), bus);
|
||||
gst_object_unref (bus);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -114,7 +114,8 @@ GST_START_TEST (test_message_state_changed)
|
|||
fail_unless (bin != NULL, "Could not create bin");
|
||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
bus = GST_ELEMENT_BUS (bin);
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT_CAST (bin), bus);
|
||||
|
||||
/* change state, spawning a message, causing an incref on the bin */
|
||||
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
|
||||
|
@ -132,6 +133,7 @@ GST_START_TEST (test_message_state_changed)
|
|||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (bin);
|
||||
}
|
||||
|
||||
|
@ -148,14 +150,15 @@ GST_START_TEST (test_message_state_changed_child)
|
|||
fail_unless (bin != NULL, "Could not create bin");
|
||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT_CAST (bin), bus);
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
fail_if (src == NULL, "Could not create fakesrc");
|
||||
gst_bin_add (bin, src);
|
||||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
|
||||
bus = GST_ELEMENT_BUS (bin);
|
||||
|
||||
/* change state, spawning two messages:
|
||||
* - first for fakesrc, forwarded to bin's bus, causing incref on fakesrc
|
||||
* - second for bin, causing an incref on the bin */
|
||||
|
@ -189,6 +192,7 @@ GST_START_TEST (test_message_state_changed_child)
|
|||
ASSERT_OBJECT_REFCOUNT (bin, "bin", 1);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (bin);
|
||||
}
|
||||
|
||||
|
@ -224,7 +228,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_pipeline_get_bus (pipeline);
|
||||
|
||||
/* change state to READY, spawning three messages */
|
||||
GST_DEBUG ("setting pipeline to READY");
|
||||
|
@ -232,7 +236,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
== GST_STATE_CHANGE_SUCCESS);
|
||||
|
||||
/* each object is referenced by a message */
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 2);
|
||||
|
@ -240,7 +244,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
pop_messages (bus, 3);
|
||||
fail_if ((gst_bus_pop (bus)) != NULL);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
@ -260,7 +264,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
pop_messages (bus, 3);
|
||||
fail_if ((gst_bus_pop (bus)) != NULL);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
@ -279,7 +283,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
pop_messages (bus, 3);
|
||||
fail_if ((gst_bus_pop (bus)) != NULL);
|
||||
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (bus, "bus", 2);
|
||||
ASSERT_OBJECT_REFCOUNT (src, "src", 1);
|
||||
/* sink might have an extra reference if it's still blocked on preroll */
|
||||
ASSERT_OBJECT_REFCOUNT_BETWEEN (sink, "sink", 1, 2);
|
||||
|
@ -311,6 +315,7 @@ GST_START_TEST (test_message_state_changed_children)
|
|||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
@ -324,6 +329,9 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
bin = gst_element_factory_make ("bin", NULL);
|
||||
fail_unless (bin != NULL, "Could not create bin");
|
||||
|
||||
bus = g_object_new (gst_bus_get_type (), NULL);
|
||||
gst_element_set_bus (GST_ELEMENT_CAST (bin), bus);
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
fail_if (src == NULL, "Could not create fakesrc");
|
||||
sink = gst_element_factory_make ("fakesink", NULL);
|
||||
|
@ -334,15 +342,13 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
|
||||
fail_unless (gst_element_link (src, sink), "could not link src and sink");
|
||||
|
||||
bus = GST_ELEMENT_BUS (bin);
|
||||
|
||||
/* change state, spawning two times three messages, minus one async */
|
||||
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED)
|
||||
== GST_STATE_CHANGE_ASYNC);
|
||||
|
||||
pop_messages (bus, 5);
|
||||
|
||||
fail_unless (gst_bus_have_pending (bus, GST_MESSAGE_ANY) == FALSE,
|
||||
fail_unless (gst_bus_have_pending (bus) == FALSE,
|
||||
"Unexpected messages on bus");
|
||||
|
||||
gst_bin_watch_for_state_change (GST_BIN (bin));
|
||||
|
@ -350,7 +356,7 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
/* should get the bin's state change message now */
|
||||
pop_messages (bus, 1);
|
||||
|
||||
fail_unless (gst_bus_have_pending (bus, GST_MESSAGE_ANY) == FALSE,
|
||||
fail_unless (gst_bus_have_pending (bus) == FALSE,
|
||||
"Unexpected messages on bus");
|
||||
|
||||
fail_unless (gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PLAYING)
|
||||
|
@ -365,7 +371,7 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
|
||||
pop_messages (bus, 3);
|
||||
|
||||
fail_unless (gst_bus_have_pending (bus, GST_MESSAGE_ANY) == FALSE,
|
||||
fail_unless (gst_bus_have_pending (bus) == FALSE,
|
||||
"Unexpected messages on bus");
|
||||
|
||||
/* setting bin to NULL flushes the bus automatically */
|
||||
|
@ -373,6 +379,7 @@ GST_START_TEST (test_watch_for_state_change)
|
|||
== GST_STATE_CHANGE_SUCCESS);
|
||||
|
||||
/* clean up */
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (bin);
|
||||
}
|
||||
|
||||
|
@ -458,7 +465,7 @@ GST_START_TEST (test_children_state_change_order_flagged_sink)
|
|||
pipeline = gst_pipeline_new (NULL);
|
||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
fail_unless (bus != NULL, "Pipeline has no bus?!");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
|
@ -531,6 +538,7 @@ GST_START_TEST (test_children_state_change_order_flagged_sink)
|
|||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
@ -548,7 +556,7 @@ GST_START_TEST (test_children_state_change_order_semi_sink)
|
|||
pipeline = gst_pipeline_new (NULL);
|
||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
fail_unless (bus != NULL, "Pipeline has no bus?!");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
|
@ -623,6 +631,7 @@ GST_START_TEST (test_children_state_change_order_semi_sink)
|
|||
ASSERT_OBJECT_REFCOUNT (sink, "sink", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
@ -637,7 +646,7 @@ GST_START_TEST (test_children_state_change_order_two_sink)
|
|||
pipeline = gst_pipeline_new (NULL);
|
||||
fail_unless (pipeline != NULL, "Could not create pipeline");
|
||||
|
||||
bus = GST_ELEMENT_BUS (pipeline);
|
||||
bus = gst_element_get_bus (pipeline);
|
||||
fail_unless (bus != NULL, "Pipeline has no bus?!");
|
||||
|
||||
src = gst_element_factory_make ("fakesrc", NULL);
|
||||
|
@ -718,6 +727,7 @@ GST_START_TEST (test_children_state_change_order_two_sink)
|
|||
ASSERT_OBJECT_REFCOUNT (sink2, "sink2", 1);
|
||||
ASSERT_OBJECT_REFCOUNT (pipeline, "pipeline", 1);
|
||||
|
||||
gst_object_unref (bus);
|
||||
gst_object_unref (pipeline);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue