From 14a89b387eb12597104613d8bda1cea01607aec5 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 28 Apr 2006 15:48:50 +0000 Subject: [PATCH] gst/gstutils.c: Added some more docs. Original commit message from CVS: * gst/gstutils.c: (push_and_ref): Added some more docs. Fix refcount issue whith gst_element_found_tags() helper function. Fixes #338335 * tests/check/gst/gstutils.c: (GST_START_TEST), (gst_utils_suite): Added testsuite for gst_element_found_tags(). --- ChangeLog | 10 ++++++++++ gst/gstutils.c | 6 +++++- tests/check/gst/gstutils.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index b926208296..a2a265ab09 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2006-04-28 Wim Taymans + + * gst/gstutils.c: (push_and_ref): + Added some more docs. + Fix refcount issue whith gst_element_found_tags() helper + function. Fixes #338335 + + * tests/check/gst/gstutils.c: (GST_START_TEST), (gst_utils_suite): + Added testsuite for gst_element_found_tags(). + 2006-04-28 Michael Smith * gst/gstvalue.c: (gst_value_serialize_flags): diff --git a/gst/gstutils.c b/gst/gstutils.c index 56b98b7dfb..15bc66f136 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -482,6 +482,7 @@ overflow: * This function can potentially be very slow if denom > G_MAXUINT32. * * Returns: @val * @num / @denom, trying to avoid overflows. + * In the case of an overflow, this function returns G_MAXUINT64. */ guint64 gst_util_uint64_scale (guint64 val, guint64 num, guint64 denom) @@ -528,7 +529,8 @@ do_int64: * * @num and @denom must be positive integers. @denom cannot be 0. * - * Returns: @val * @num / @denom, avoiding overflow and loss of precision + * Returns: @val * @num / @denom, avoiding overflow and loss of precision. + * In the case of an overflow, this function returns G_MAXUINT64. */ guint64 gst_util_uint64_scale_int (guint64 val, gint num, gint denom) @@ -3003,6 +3005,8 @@ static void push_and_ref (GstPad * pad, GstEvent * event) { gst_pad_push_event (pad, gst_event_ref (event)); + /* iterator refs pad, we unref when we are done with it */ + gst_object_unref (pad); } /** diff --git a/tests/check/gst/gstutils.c b/tests/check/gst/gstutils.c index 5399e8894b..c5e934d7b4 100644 --- a/tests/check/gst/gstutils.c +++ b/tests/check/gst/gstutils.c @@ -414,6 +414,40 @@ GST_START_TEST (test_parse_bin_from_description) GST_END_TEST; #endif +GST_START_TEST (test_element_found_tags) +{ + GstElement *pipeline, *fakesrc, *fakesink; + GstTagList *list; + GstBus *bus; + GstMessage *message; + + pipeline = gst_element_factory_make ("pipeline", NULL); + fakesrc = gst_element_factory_make ("fakesrc", NULL); + fakesink = gst_element_factory_make ("fakesink", NULL); + list = gst_tag_list_new (); + + g_object_set (fakesrc, "num-buffers", (int) 10, NULL); + + gst_bin_add_many (GST_BIN (pipeline), fakesrc, fakesink, NULL); + gst_element_link (fakesrc, fakesink); + + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + gst_element_found_tags (GST_ELEMENT (fakesrc), list); + + bus = gst_element_get_bus (pipeline); + message = gst_bus_poll (bus, GST_MESSAGE_EOS, -1); + gst_message_unref (message); + gst_object_unref (bus); + + /* FIXME: maybe also check if the fakesink receives the message */ + + gst_element_set_state (pipeline, GST_STATE_NULL); + gst_object_unref (pipeline); +} + +GST_END_TEST; + Suite * gst_utils_suite (void) { @@ -431,6 +465,7 @@ gst_utils_suite (void) #ifndef GST_DISABLE_PARSE tcase_add_test (tc_chain, test_parse_bin_from_description); #endif + tcase_add_test (tc_chain, test_element_found_tags); return s; }