From c40dba242ca04a48ed4cb7b5a30bc450e8b37c8d Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Fri, 1 Apr 2011 13:51:31 +0200 Subject: [PATCH 1/9] element: strto[u]l() returns a g[u]long --- gst/gstelement.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index 6fd1835fec..414d61be2d 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -1005,14 +1005,14 @@ _gst_element_request_pad (GstElement * element, GstPadTemplate * templ, /* Can either be %s or %d or %u, do sanity checking for %d */ if (*(str + 1) == 'd') { - gint tmp; + glong tmp; /* it's an int */ tmp = strtol (data, &endptr, 10); g_return_val_if_fail (tmp != G_MINLONG && tmp != G_MAXLONG && *endptr == '\0', NULL); } else if (*(str + 1) == 'u') { - guint tmp; + gulong tmp; /* it's an int */ tmp = strtoul (data, &endptr, 10); @@ -1100,7 +1100,7 @@ gst_element_get_request_pad (GstElement * element, const gchar * name) && strlen (name) > str - templ->name_template) { data = name + (str - templ->name_template); if (*(str + 1) == 'd') { - gint tmp; + glong tmp; /* it's an int */ tmp = strtol (data, &endptr, 10); @@ -1111,7 +1111,7 @@ gst_element_get_request_pad (GstElement * element, const gchar * name) break; } } else if (*(str + 1) == 'u') { - guint tmp; + gulong tmp; /* it's an int */ tmp = strtoul (data, &endptr, 10); From 9f3e48b55bc96a41b79a8e92859d7df3eadb433c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 Apr 2011 13:53:39 +0200 Subject: [PATCH 2/9] element: Use gint64/guint64 string parsing functions And check that the requested pad names are inside the valid gint/guint range. --- gst/gstelement.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index 414d61be2d..1b37cfd574 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -1005,18 +1005,18 @@ _gst_element_request_pad (GstElement * element, GstPadTemplate * templ, /* Can either be %s or %d or %u, do sanity checking for %d */ if (*(str + 1) == 'd') { - glong tmp; + gint64 tmp; /* it's an int */ - tmp = strtol (data, &endptr, 10); - g_return_val_if_fail (tmp != G_MINLONG && tmp != G_MAXLONG + tmp = g_ascii_strtoll (data, &endptr, 10); + g_return_val_if_fail (tmp >= G_MININT && tmp <= G_MAXINT && *endptr == '\0', NULL); } else if (*(str + 1) == 'u') { - gulong tmp; + guint64 tmp; /* it's an int */ - tmp = strtoul (data, &endptr, 10); - g_return_val_if_fail (tmp != G_MAXULONG && *endptr == '\0', NULL); + tmp = g_ascii_strtoull (data, &endptr, 10); + g_return_val_if_fail (tmp <= G_MAXUINT && *endptr == '\0', NULL); } } From 38c07bac1dbeab510de1a89439a7b7123b2f5496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Fri, 1 Apr 2011 13:56:09 +0200 Subject: [PATCH 3/9] element: When requesting an existing pad print a g_critical() instead of using an assertion Some applications are requesting the same pad name multiple times and the behaviour is undefined and different from element to element but we don't want to break applications that work just fine. In 0.11 this check should be an assertion again, although elements have to do manual checking if the pad already exists again because it can't be done in a threadsafe way here. --- gst/gstelement.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index 1b37cfd574..3133da5756 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -1021,9 +1021,13 @@ _gst_element_request_pad (GstElement * element, GstPadTemplate * templ, } pad = gst_element_get_static_pad (element, name); - if (pad) + if (pad) { gst_object_unref (pad); - g_return_val_if_fail (pad == NULL, NULL); + /* FIXME 0.11: Change this to g_return_val_if_fail() */ + g_critical ("Element %s already has a pad named %s, the behaviour of " + " gst_element_get_request_pad() for existing pads is undefined!", + GST_ELEMENT_NAME (element), name); + } } #endif From 08e189badbeffcce1ee9addbdee7023b676ce6c7 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Sat, 2 Apr 2011 14:51:18 +0100 Subject: [PATCH 4/9] utils: Avoid using "type" as name for a variable and a macro argument in GST_BOILERPLATE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This caused "re-declaration" problems. ./clutter-gst-video-sink.c: In function ‘clutter_gst_video_sink_init_interfaces’: ./clutter-gst-video-sink.c:231:1: warning: declaration of ‘ClutterGstVideoSink’ shadows a global declaration [-Wshadow] ./clutter-gst-video-sink.h:64:44: warning: shadowed declaration is here [-Wshadow] https://bugzilla.gnome.org/show_bug.cgi?id=646531 --- gst/gstutils.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gst/gstutils.h b/gst/gstutils.h index dd936584c6..d1a9fed7e0 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -216,7 +216,7 @@ type_as_function ## _implements_interface_init (GstImplementsInterfaceClass *kla } \ \ static void \ -type_as_function ## _init_interfaces (GType type) \ +type_as_function ## _init_interfaces (GType type_var) \ { \ static const GInterfaceInfo implements_iface_info = { \ (GInterfaceInitFunc) type_as_function ## _implements_interface_init,\ @@ -229,9 +229,9 @@ type_as_function ## _init_interfaces (GType type) \ NULL, \ }; \ \ - g_type_add_interface_static (type, GST_TYPE_IMPLEMENTS_INTERFACE, \ + g_type_add_interface_static (type_var, GST_TYPE_IMPLEMENTS_INTERFACE, \ &implements_iface_info); \ - g_type_add_interface_static (type, interface_type_as_macro, \ + g_type_add_interface_static (type_var, interface_type_as_macro, \ &iface_info); \ } \ \ From 439bbf1fde4b43339ded98b3765b89ef2363bcd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 3 Apr 2011 16:18:14 +0100 Subject: [PATCH 5/9] checks: ignore new funnel unit test binary --- tests/check/elements/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/check/elements/.gitignore b/tests/check/elements/.gitignore index 77c3967d76..8ab5437ad5 100644 --- a/tests/check/elements/.gitignore +++ b/tests/check/elements/.gitignore @@ -5,6 +5,7 @@ fakesink fdsrc filesink filesrc +funnel identity multiqueue queue From e1ac508cab048b623240ecfde75b66d0a7e435ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Sun, 3 Apr 2011 16:18:54 +0100 Subject: [PATCH 6/9] docs: add pointer to part-seeking.txt design docs to event seek flags docs --- gst/gstevent.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gst/gstevent.h b/gst/gstevent.h index cf61369877..e7ce4536fa 100644 --- a/gst/gstevent.h +++ b/gst/gstevent.h @@ -298,7 +298,11 @@ typedef enum { * When doing fast forward (rate > 1.0) or fast reverse (rate < -1.0) trickmode * playback, the @GST_SEEK_FLAG_SKIP flag can be used to instruct decoders * and demuxers to adjust the playback rate by skipping frames. This can improve - * performance and decrease CPU usage because not all frames need to be decoded. + * performance and decrease CPU usage because not all frames need to be decoded. + * + * Also see part-seeking.txt in the GStreamer design documentation for more + * details on the meaning of these flags and the behaviour expected of + * elements that handle them. */ typedef enum { GST_SEEK_FLAG_NONE = 0, From d0d27e83fe2338b20a641d62fdcfa232e7a913ce Mon Sep 17 00:00:00 2001 From: Thomas Kristensen Date: Fri, 25 Mar 2011 15:56:07 +0100 Subject: [PATCH 7/9] poll: don't call WSAWaitForMultipleEvents with no events Fixes error caught by Microsoft Application Verifier. --- gst/gstpoll.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gst/gstpoll.c b/gst/gstpoll.c index ba9fdc8bca..fbcf2b2e3a 100644 --- a/gst/gstpoll.c +++ b/gst/gstpoll.c @@ -1375,8 +1375,13 @@ gst_poll_wait (GstPoll * set, GstClockTime timeout) t = 0; } - wait_ret = WSAWaitForMultipleEvents (set->active_events->len, - (HANDLE *) set->active_events->data, FALSE, t, FALSE); + if (set->active_events->len != 0) { + wait_ret = WSAWaitForMultipleEvents (set->active_events->len, + (HANDLE *) set->active_events->data, FALSE, t, FALSE); + } else { + wait_ret = WSA_WAIT_FAILED; + WSASetLastError (WSA_INVALID_PARAMETER); + } if (ignore_count == 0 && wait_ret == WSA_WAIT_TIMEOUT) { res = 0; From eba33c1de11fc7fb63fb31a764d3c16698eea490 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Mon, 4 Apr 2011 10:18:14 +0200 Subject: [PATCH 8/9] structure: Don't allow invalid GDates in all structures and don't allow NULL GDates in taglists Some code (e.g. gstvorbistag.c) assumes non-NULL GDates in taglists and explodes otherwise and NULL or invalid GDates don't make much sense anyway. --- gst/gststructure.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/gst/gststructure.c b/gst/gststructure.c index 011639a41a..92b6b93d35 100644 --- a/gst/gststructure.c +++ b/gst/gststructure.c @@ -782,6 +782,25 @@ gst_structure_set_field (GstStructure * structure, GstStructureField * field) g_value_unset (&field->value); return; } + } else if (G_UNLIKELY (GST_VALUE_HOLDS_DATE (&field->value))) { + const GDate *d; + + d = gst_value_get_date (&field->value); + /* only check for NULL GDates in taglists, as they might make sense + * in other, generic structs */ + if (G_UNLIKELY ((IS_TAGLIST (structure) && d == NULL))) { + GIT_G_WARNING ("Trying to set NULL GDate on field '%s' on taglist. " + "Please file a bug.", g_quark_to_string (field->name)); + g_value_unset (&field->value); + return; + } else if (G_UNLIKELY (d != NULL && !g_date_valid (d))) { + g_warning + ("Trying to set invalid GDate on %s field '%s'. Please file a bug.", + IS_TAGLIST (structure) ? "taglist" : "structure", + g_quark_to_string (field->name)); + g_value_unset (&field->value); + return; + } } for (i = 0; i < len; i++) { From 7c6d9c2725a9632fbd96fd41b60ed814649d3bec Mon Sep 17 00:00:00 2001 From: Andoni Morales Alastruey Date: Mon, 4 Apr 2011 03:33:46 +0200 Subject: [PATCH 9/9] gstpoll: retry reading the control socket to release properly all wakeups if set->control_pending is set to 0 but we didn't not succed reading the control socket, future calls to gst_poll_wait() will be awaiken by the control socket which will not be released properly because set->control_pending is already 0, causing an infinite loop. --- gst/gstpoll.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gst/gstpoll.c b/gst/gstpoll.c index fbcf2b2e3a..76a7a30e6a 100644 --- a/gst/gstpoll.c +++ b/gst/gstpoll.c @@ -210,8 +210,11 @@ release_all_wakeup (GstPoll * set) /* try to remove all pending control messages */ if (g_atomic_int_compare_and_exchange (&set->control_pending, old, 0)) { /* we managed to remove all messages, read the control socket */ - (void) RELEASE_EVENT (set); - break; + if (RELEASE_EVENT (set)) + break; + else + /* retry again until we read it successfully */ + g_atomic_int_exchange_and_add (&set->control_pending, 1); } } return old;