From abda75bcf58e2fdf7fde5c75caa5fe569c50b1f9 Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Tue, 9 Aug 2011 22:29:44 +0200 Subject: [PATCH 01/14] gst: use GstDebugLevel enum type to fix a warning building with ICC https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gst.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gst/gst.c b/gst/gst.c index e109effdbd..aa187f64f3 100644 --- a/gst/gst.c +++ b/gst/gst.c @@ -217,7 +217,7 @@ parse_debug_category (gchar * str, const gchar ** category) } static gboolean -parse_debug_level (gchar * str, gint * level) +parse_debug_level (gchar * str, GstDebugLevel * level) { if (!str) return FALSE; @@ -227,7 +227,7 @@ parse_debug_level (gchar * str, gint * level) if (str[0] != NUL && str[1] == NUL && str[0] >= '0' && str[0] < '0' + GST_LEVEL_COUNT) { - *level = str[0] - '0'; + *level = (GstDebugLevel) (str[0] - '0'); return TRUE; } @@ -249,7 +249,7 @@ parse_debug_list (const gchar * list) gchar **values = g_strsplit (*walk, ":", 2); if (values[0] && values[1]) { - gint level; + GstDebugLevel level; const gchar *category; if (parse_debug_category (values[0], &category) @@ -259,7 +259,7 @@ parse_debug_list (const gchar * list) g_strfreev (values); } else { - gint level; + GstDebugLevel level; if (parse_debug_level (*walk, &level)) gst_debug_set_default_threshold (level); @@ -902,9 +902,9 @@ parse_one_option (gint opt, const gchar * arg, GError ** err) } #ifndef GST_DISABLE_GST_DEBUG case ARG_DEBUG_LEVEL:{ - gint tmp = 0; + GstDebugLevel tmp = GST_LEVEL_NONE; - tmp = strtol (arg, NULL, 0); + tmp = (GstDebugLevel) strtol (arg, NULL, 0); if (tmp >= 0 && tmp < GST_LEVEL_COUNT) { gst_debug_set_default_threshold (tmp); } From d99d270a69b31a945122998dab6959ad4cab763a Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Tue, 9 Aug 2011 22:48:53 +0200 Subject: [PATCH 02/14] caps: define GST_CAPS_FLAGS_NONE for consistency with other enumerations Use them to fix warnings when building with ICC. API: GST_CAPS_FLAGS_NONE https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gstcaps.c | 4 ++-- gst/gstcaps.h | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/gst/gstcaps.c b/gst/gstcaps.c index 6cc673132d..df348beb16 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -166,7 +166,7 @@ gst_caps_new_empty (void) caps->type = GST_TYPE_CAPS; caps->refcount = 1; - caps->flags = 0; + caps->flags = GST_CAPS_FLAGS_NONE; caps->structs = g_ptr_array_new (); /* the 32 has been determined by logging caps sizes in _gst_caps_free * but g_ptr_array uses 16 anyway if it expands once, so this does not help @@ -492,7 +492,7 @@ gst_static_caps_get (GstStaticCaps * static_caps) * of the result caps to 0 so that other threads don't run away with the * caps while we are constructing it. */ temp.type = GST_TYPE_CAPS; - temp.flags = 0; + temp.flags = GST_CAPS_FLAGS_NONE; temp.structs = g_ptr_array_new (); /* initialize the caps to a refcount of 1 so the caps can be writable for diff --git a/gst/gstcaps.h b/gst/gstcaps.h index b7c5c0fc3a..47c0d33fda 100644 --- a/gst/gstcaps.h +++ b/gst/gstcaps.h @@ -34,12 +34,14 @@ G_BEGIN_DECLS /** * GstCapsFlags: + * @GST_CAPS_FLAGS_NONE: no extra flags (Since 0.10.36) * @GST_CAPS_FLAGS_ANY: Caps has no specific content, but can contain * anything. * * Extra flags for a caps. */ typedef enum { + GST_CAPS_FLAGS_NONE = 0, GST_CAPS_FLAGS_ANY = (1 << 0) } GstCapsFlags; From b30b78c505e3543ad2dccee0e09a394beca8d98c Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Tue, 9 Aug 2011 23:26:13 +0200 Subject: [PATCH 03/14] debugutils: use GST_STATE_VOID_PENDING for GstState instead of 0 Fixes a warning reported by ICC. https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gstdebugutils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst/gstdebugutils.c b/gst/gstdebugutils.c index f83ccf0839..a552cc00ef 100644 --- a/gst/gstdebugutils.c +++ b/gst/gstdebugutils.c @@ -77,7 +77,7 @@ debug_dump_get_element_state (GstElement * element) { gchar *state_name = NULL; const gchar *state_icons = "~0-=>"; - GstState state = 0, pending = 0; + GstState state = GST_STATE_VOID_PENDING, pending = GST_STATE_VOID_PENDING; gst_element_get_state (element, &state, &pending, 0); if (pending == GST_STATE_VOID_PENDING) { From 7b434c44bfafcbe62cbfbac66fd8dc5968792deb Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Tue, 9 Aug 2011 23:33:43 +0200 Subject: [PATCH 04/14] gsterror: explicitly cast to the right GstGError code enum types Fixes warning #188: enumerated type mixed with another type reported by ICC. https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gsterror.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gst/gsterror.c b/gst/gsterror.c index 0183c34873..f3f2d22f48 100644 --- a/gst/gsterror.c +++ b/gst/gsterror.c @@ -309,13 +309,13 @@ gst_error_get_message (GQuark domain, gint code) const gchar *message = NULL; if (domain == GST_CORE_ERROR) - message = gst_error_get_core_error (code); + message = gst_error_get_core_error ((GstCoreError) code); else if (domain == GST_LIBRARY_ERROR) - message = gst_error_get_library_error (code); + message = gst_error_get_library_error ((GstLibraryError) code); else if (domain == GST_RESOURCE_ERROR) - message = gst_error_get_resource_error (code); + message = gst_error_get_resource_error ((GstResourceError) code); else if (domain == GST_STREAM_ERROR) - message = gst_error_get_stream_error (code); + message = gst_error_get_stream_error ((GstStreamError) code); else { g_warning ("No error messages for domain %s", g_quark_to_string (domain)); return g_strdup_printf (_("No error message for domain %s."), From 89239d85cc76833df70b7b06a54a47d673ccf96a Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Tue, 9 Aug 2011 23:42:26 +0200 Subject: [PATCH 05/14] event: explicitly cast to the right enum types Fixes warning #188: enumerated type mixed with another type reported by ICC. https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gstevent.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/gst/gstevent.c b/gst/gstevent.c index 7e28e9192a..7de59b9553 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -664,7 +664,7 @@ gst_event_parse_new_segment_full (GstEvent * event, gboolean * update, g_value_get_double (gst_structure_id_get_value (structure, GST_QUARK (APPLIED_RATE))); if (G_LIKELY (format)) - *format = + *format = (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (FORMAT))); if (G_LIKELY (start)) @@ -776,7 +776,7 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format, structure = event->structure; if (format) - *format = + *format = (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (FORMAT))); if (minsize) @@ -940,7 +940,7 @@ gst_event_parse_qos_full (GstEvent * event, GstQOSType * type, structure = event->structure; if (type) - *type = + *type = (GstQOSType) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (TYPE))); if (proportion) @@ -1068,15 +1068,15 @@ gst_event_parse_seek (GstEvent * event, gdouble * rate, g_value_get_double (gst_structure_id_get_value (structure, GST_QUARK (RATE))); if (format) - *format = + *format = (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (FORMAT))); if (flags) - *flags = + *flags = (GstSeekFlags) g_value_get_flags (gst_structure_id_get_value (structure, GST_QUARK (FLAGS))); if (start_type) - *start_type = + *start_type = (GstSeekType) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (CUR_TYPE))); if (start) @@ -1084,7 +1084,7 @@ gst_event_parse_seek (GstEvent * event, gdouble * rate, g_value_get_int64 (gst_structure_id_get_value (structure, GST_QUARK (CUR))); if (stop_type) - *stop_type = + *stop_type = (GstSeekType) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (STOP_TYPE))); if (stop) @@ -1234,7 +1234,8 @@ gst_event_parse_step (GstEvent * event, GstFormat * format, guint64 * amount, structure = event->structure; if (format) - *format = g_value_get_enum (gst_structure_id_get_value (structure, + *format = + (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (FORMAT))); if (amount) *amount = g_value_get_uint64 (gst_structure_id_get_value (structure, From 2271b6dc9a339a70b94090663258545f28d7b7e6 Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Wed, 10 Aug 2011 11:07:49 +0200 Subject: [PATCH 06/14] gststate: explicitly cast to the enum type Fixes warning #188: enumerated type mixed with another type reported by ICC. https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gstelement.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst/gstelement.h b/gst/gstelement.h index 74a0e2ce9b..f0d23539ed 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -150,7 +150,7 @@ typedef enum { * Given a current state @cur and a target state @pending, calculate the next (intermediate) * #GstState. */ -#define GST_STATE_GET_NEXT(cur,pending) ((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur))) +#define GST_STATE_GET_NEXT(cur,pending) ((GstState)((cur) + __GST_SIGN ((gint)(pending) - (gint)(cur)))) /** * GST_STATE_TRANSITION: * @cur: A current state From c56881a02672f1e1d48479abbf6fb2165c46b1b4 Mon Sep 17 00:00:00 2001 From: Josep Torra Date: Wed, 10 Aug 2011 11:39:23 +0200 Subject: [PATCH 07/14] buffer: explicitly cast to the enum type Fixes warning #188: enumerated type mixed with another type reported by ICC. https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gstbuffer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index ad48315c6a..070c7d8408 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -412,7 +412,7 @@ typedef enum { * * Since: 0.10.13 */ -#define GST_BUFFER_COPY_ALL (GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_CAPS) +#define GST_BUFFER_COPY_ALL ((GstBufferCopyFlags) (GST_BUFFER_COPY_FLAGS | GST_BUFFER_COPY_TIMESTAMPS | GST_BUFFER_COPY_CAPS)) /* copies metadata into newly allocated buffer */ void gst_buffer_copy_metadata (GstBuffer *dest, const GstBuffer *src, From 4985d2a954b293e56d670d10e2448ddd52d574d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 15 Aug 2011 21:05:34 +0100 Subject: [PATCH 08/14] caps: fix compiler warning reported by ICC The MAX macro expands to code that checks if an unsigned integer is < 0. Fixes warning #186: pointless comparison of unsigned integer reported by ICC. https://bugzilla.gnome.org/show_bug.cgi?id=656265 --- gst/gstcaps.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gst/gstcaps.c b/gst/gstcaps.c index df348beb16..94b700019d 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -1239,7 +1239,7 @@ gst_caps_can_intersect (const GstCaps * caps1, const GstCaps * caps2) j = MIN (i, len1 - 1); /* subset index stays 0 until i reaches superset->structs->len, then it * counts up from 1 to subset->structs->len - 1 */ - k = MAX (0, i - j); + k = (i > j) ? (i - j) : 0; /* MAX (0, i - j) */ /* now run the diagonal line, end condition is the left or bottom * border */ @@ -1310,7 +1310,7 @@ gst_caps_intersect_zig_zag (const GstCaps * caps1, const GstCaps * caps2) j = MIN (i, len1 - 1); /* caps2 index stays 0 until i reaches caps1->structs->len, then it counts * up from 1 to caps2->structs->len - 1 */ - k = MAX (0, i - j); + k = (i > j) ? (i - j) : 0; /* MAX (0, i - j) */ /* now run the diagonal line, end condition is the left or bottom * border */ From eb08ed6ed0a33e76a2190e3e036c899b1a222493 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Tue, 16 Aug 2011 17:19:29 +0100 Subject: [PATCH 09/14] docs: fix typo in element factory documentation --- gst/gstelementfactory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 23a25387d1..0eca4576d7 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -746,7 +746,7 @@ typedef struct * @factory: a #GstElementFactory * @type: a #GstElementFactoryListType * - * Check if @factory if of the given types. + * Check if @factory is of the given types. * * Returns: %TRUE if @factory is of @type. * From 7043bf9d55664282a4535093282527779dab4368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 18 Aug 2011 20:44:01 +0100 Subject: [PATCH 10/14] baseparse: fix crash on seek from streaming thread on newsegment event Event if it's not allowed, we can easily prevent it, so let's do that. https://bugzilla.gnome.org/show_bug.cgi?id=656771 --- libs/gst/base/gstbaseparse.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 59865c2775..65160c362a 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -1851,10 +1851,14 @@ gst_base_parse_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) parse->priv->close_segment = NULL; } if (G_UNLIKELY (parse->priv->pending_segment)) { + GstEvent *pending_segment; + + pending_segment = parse->priv->pending_segment; + parse->priv->pending_segment = NULL; + GST_DEBUG_OBJECT (parse, "%s push pending segment", parse->priv->pad_mode == GST_ACTIVATE_PULL ? "loop" : "chain"); - gst_pad_push_event (parse->srcpad, parse->priv->pending_segment); - parse->priv->pending_segment = NULL; + gst_pad_push_event (parse->srcpad, pending_segment); /* have caps; check identity */ gst_base_parse_check_media (parse); From c7f2e85d86e99f54069e4a89283ceb310a4871ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 18 Aug 2011 20:46:01 +0100 Subject: [PATCH 11/14] baseparse: don't use == in debug string It messes up GST_DEBUG=*:5 make foo/bar.valgrind, because our Makefile looks for '==' as marker of valgrind output. --- libs/gst/base/gstbaseparse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index 65160c362a..a5a2cd00bd 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -1560,7 +1560,7 @@ gst_base_parse_check_media (GstBaseParse * parse) parse->priv->is_video = FALSE; } - GST_DEBUG_OBJECT (parse, "media is video == %d", parse->priv->is_video); + GST_DEBUG_OBJECT (parse, "media is video: %d", parse->priv->is_video); } /* takes ownership of frame */ From a3611c139a4a0178c73ac29d5b105cbbcba7dc33 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Sat, 20 Aug 2011 09:56:01 +0200 Subject: [PATCH 12/14] docs: small clarification in the gst_element_get_request_pad docs Make it more obvious that one should pass the template name. --- gst/gstelement.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index ddbba3e409..ac13720660 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -1047,8 +1047,8 @@ _gst_element_request_pad (GstElement * element, GstPadTemplate * templ, * @element: a #GstElement to find a request pad of. * @name: the name of the request #GstPad to retrieve. * - * Retrieves a pad from the element by name. This version only retrieves - * request pads. The pad should be released with + * Retrieves a pad from the element by name (e.g. "src_%d"). This version only + * retrieves request pads. The pad should be released with * gst_element_release_request_pad(). * * This method is slow and will be deprecated in the future. New code should From cce32ba0a29cdebc34cf6bf66e72a3f554be3028 Mon Sep 17 00:00:00 2001 From: Stefan Kost Date: Sat, 20 Aug 2011 14:07:55 +0200 Subject: [PATCH 13/14] docs: more clarification for element docs Don't suggest deprecated method in the desction docs and try to be more helpful in other places by suggesting related functions. --- gst/gstelement.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index ac13720660..17c0c61bb2 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -41,7 +41,10 @@ * Core and plug-in writers can add and remove pads with gst_element_add_pad() * and gst_element_remove_pad(). * - * A pad of an element can be retrieved by name with gst_element_get_pad(). + * An existing pad of an element can be retrieved by name with + * gst_element_get_static_pad(). A new dynamic pad can be created using + * gst_element_request_pad() with a #GstPadTemplate or + * gst_element_get_request_pad() with the template name such as "src_%d". * An iterator of all pads can be retrieved with gst_element_iterate_pads(). * * Elements can be linked through their pads. @@ -1154,6 +1157,8 @@ gst_element_get_request_pad (GstElement * element, const gchar * name) * request. Can be %NULL. * * Retrieves a request pad from the element according to the provided template. + * Pad templates can be looked up using + * gst_element_factory_get_static_pad_templates(). * * If the @caps are specified and the element implements thew new * request_new_pad_full virtual method, the element will use them to select @@ -1242,8 +1247,9 @@ gst_element_iterate_pad_list (GstElement * element, GList ** padlist) * gst_element_iterate_pads: * @element: a #GstElement to iterate pads of. * - * Retrieves an iterattor of @element's pads. The iterator should - * be freed after usage. + * Retrieves an iterator of @element's pads. The iterator should + * be freed after usage. Also more specialized iterators exists such as + * gst_element_iterate_src_pads() or gst_element_iterate_sink_pads(). * * Returns: (transfer full): the #GstIterator of #GstPad. Unref each pad * after use. From ec6e452f6314b10e883c6f95366867a02c775ff0 Mon Sep 17 00:00:00 2001 From: David Schleef Date: Sun, 21 Aug 2011 14:07:08 -0700 Subject: [PATCH 14/14] object: make gst_object_replace() atomic --- gst/gstobject.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gst/gstobject.c b/gst/gstobject.c index f06d798e47..8efadeb4cd 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -421,10 +421,14 @@ gst_object_sink (gpointer object) * * Make sure not to LOCK @oldobj because it might be unreffed * which could cause a deadlock when it is disposed. + * + * Since 0.10.36, this function operates atomically. */ void gst_object_replace (GstObject ** oldobj, GstObject * newobj) { + GstObject *oldptr; + g_return_if_fail (oldobj != NULL); g_return_if_fail (*oldobj == NULL || GST_IS_OBJECT (*oldobj)); g_return_if_fail (newobj == NULL || GST_IS_OBJECT (newobj)); @@ -437,14 +441,14 @@ gst_object_replace (GstObject ** oldobj, GstObject * newobj) newobj ? G_OBJECT (newobj)->ref_count : 0); #endif - if (G_LIKELY (*oldobj != newobj)) { - if (newobj) - gst_object_ref (newobj); - if (*oldobj) - gst_object_unref (*oldobj); - - *oldobj = newobj; - } + if (newobj) + g_object_ref (newobj); + do { + oldptr = *oldobj; + } while (!g_atomic_pointer_compare_and_exchange ((void *) oldobj, + oldptr, newobj)); + if (oldptr) + g_object_unref (oldptr); } /* dispose is called when the object has to release all links