diff --git a/gst/gst.c b/gst/gst.c index 591d4b0e5e..667650d546 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); @@ -909,9 +909,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); } diff --git a/gst/gstbuffer.h b/gst/gstbuffer.h index c35b5c94b6..8d4c692532 100644 --- a/gst/gstbuffer.h +++ b/gst/gstbuffer.h @@ -381,7 +381,7 @@ typedef enum { * Combination of all possible fields that can be copied with * gst_buffer_copy_into(). */ -#define GST_BUFFER_COPY_ALL (GST_BUFFER_COPY_METADATA | GST_BUFFER_COPY_MEMORY) +#define GST_BUFFER_COPY_ALL ((GstBufferCopyFlags)(GST_BUFFER_COPY_METADATA | GST_BUFFER_COPY_MEMORY)) /* copies memory or metadata into newly allocated buffer */ void gst_buffer_copy_into (GstBuffer *dest, GstBuffer *src, diff --git a/gst/gstcaps.c b/gst/gstcaps.c index a157d5c02d..db4e067b9f 100644 --- a/gst/gstcaps.c +++ b/gst/gstcaps.c @@ -1116,7 +1116,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 */ @@ -1187,7 +1187,7 @@ gst_caps_intersect_zig_zag (const GstCaps * caps1, const GstCaps * caps2) j = MIN (i, len1 - 1); /* caps2 index stays 0 until i reaches GST_CAPS_LEN (caps1), then it counts * up from 1 to GST_CAPS_LEN (caps2) - 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 */ diff --git a/gst/gstdebugutils.c b/gst/gstdebugutils.c index 2a09dd0aa1..de74850fb7 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) { diff --git a/gst/gstelement.c b/gst/gstelement.c index 14bd352fea..9c41828984 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. @@ -1022,8 +1025,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 @@ -1129,6 +1132,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 @@ -1169,8 +1174,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. diff --git a/gst/gstelement.h b/gst/gstelement.h index a9f2f000b0..9cc30ed1b8 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -151,7 +151,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 diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index a03066a728..647674ecf9 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -626,7 +626,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. * 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."), diff --git a/gst/gstevent.c b/gst/gstevent.c index d5d0b8f3b4..2b88751d53 100644 --- a/gst/gstevent.c +++ b/gst/gstevent.c @@ -803,7 +803,7 @@ gst_event_parse_buffer_size (GstEvent * event, GstFormat * format, structure = GST_EVENT_STRUCTURE (event); if (format) - *format = + *format = (GstFormat) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (FORMAT))); if (minsize) @@ -919,7 +919,7 @@ gst_event_parse_qos (GstEvent * event, GstQOSType * type, structure = GST_EVENT_STRUCTURE (event); if (type) - *type = + *type = (GstQOSType) g_value_get_enum (gst_structure_id_get_value (structure, GST_QUARK (TYPE))); if (proportion) @@ -1047,15 +1047,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) @@ -1063,7 +1063,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) @@ -1213,7 +1213,8 @@ gst_event_parse_step (GstEvent * event, GstFormat * format, guint64 * amount, structure = GST_EVENT_STRUCTURE (event); 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, diff --git a/gst/gstobject.c b/gst/gstobject.c index 9b3c29e95d..ed1eb22019 100644 --- a/gst/gstobject.c +++ b/gst/gstobject.c @@ -300,10 +300,14 @@ gst_object_ref_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)); @@ -316,14 +320,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 diff --git a/libs/gst/base/gstbaseparse.c b/libs/gst/base/gstbaseparse.c index b58e9e67e4..b87a5c8336 100644 --- a/libs/gst/base/gstbaseparse.c +++ b/libs/gst/base/gstbaseparse.c @@ -1586,7 +1586,7 @@ gst_base_parse_check_media (GstBaseParse * parse) if (caps) gst_caps_unref (caps); - 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 */ @@ -1862,10 +1862,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);