summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Dröge <sebastian@centricular.com>2013-10-30 21:53:36 +0100
committerSebastian Dröge <sebastian@centricular.com>2013-10-30 21:53:36 +0100
commit7e5dc030f5e39998169166a8b1a734f3bf7efc62 (patch)
tree727c4c33646b39fb56b545bd1119f4c4b8316e40
parentc76aaaaa1d3b9e33846ef2d07af3bcb3accef5c1 (diff)
utils: Add some attributes and reorganize code to fix compiler warnings
gstutils.c:3659:41: error: format string is not a string literal [-Werror,-Wformat-nonliteral] gchar *expanded = g_strdup_vprintf (stream_id, var_args); https://bugzilla.gnome.org/show_bug.cgi?id=710621
-rw-r--r--gst/gstutils.c74
-rw-r--r--gst/gstutils.h6
2 files changed, 47 insertions, 33 deletions
diff --git a/gst/gstutils.c b/gst/gstutils.c
index 33f518ce0..b9ceb07de 100644
--- a/gst/gstutils.c
+++ b/gst/gstutils.c
@@ -3563,32 +3563,9 @@ gst_util_fraction_compare (gint a_n, gint a_d, gint b_n, gint b_d)
g_return_val_if_reached (0);
}
-/**
- * gst_pad_create_stream_id_printf_valist:
- * @pad: A source #GstPad
- * @parent: Parent #GstElement of @pad
- * @stream_id: (allow-none): The stream-id
- * @var_args: parameters for the @stream_id format string
- *
- * Creates a stream-id for the source #GstPad @pad by combining the
- * upstream information with the optional @stream_id of the stream
- * of @pad. @pad must have a parent #GstElement and which must have zero
- * or one sinkpad. @stream_id can only be %NULL if the parent element
- * of @pad has only a single source pad.
- *
- * This function generates an unique stream-id by getting the upstream
- * stream-start event stream ID and appending @stream_id to it. If the
- * element has no sinkpad it will generate an upstream stream-id by
- * doing an URI query on the element and in the worst case just uses
- * a random number. Source elements that don't implement the URI
- * handler interface should ideally generate a unique, deterministic
- * stream-id manually instead.
- *
- * Returns: A stream-id for @pad. g_free() after usage.
- */
-gchar *
-gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
- const gchar * stream_id, va_list var_args)
+static gchar *
+gst_pad_create_stream_id_internal (GstPad * pad, GstElement * parent,
+ const gchar * stream_id)
{
GstEvent *upstream_event;
gchar *upstream_stream_id = NULL, *new_stream_id;
@@ -3656,9 +3633,7 @@ gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
}
if (stream_id) {
- gchar *expanded = g_strdup_vprintf (stream_id, var_args);
- new_stream_id = g_strconcat (upstream_stream_id, "/", expanded, NULL);
- g_free (expanded);
+ new_stream_id = g_strconcat (upstream_stream_id, "/", stream_id, NULL);
} else {
new_stream_id = g_strdup (upstream_stream_id);
}
@@ -3669,6 +3644,45 @@ gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
}
/**
+ * gst_pad_create_stream_id_printf_valist:
+ * @pad: A source #GstPad
+ * @parent: Parent #GstElement of @pad
+ * @stream_id: (allow-none): The stream-id
+ * @var_args: parameters for the @stream_id format string
+ *
+ * Creates a stream-id for the source #GstPad @pad by combining the
+ * upstream information with the optional @stream_id of the stream
+ * of @pad. @pad must have a parent #GstElement and which must have zero
+ * or one sinkpad. @stream_id can only be %NULL if the parent element
+ * of @pad has only a single source pad.
+ *
+ * This function generates an unique stream-id by getting the upstream
+ * stream-start event stream ID and appending @stream_id to it. If the
+ * element has no sinkpad it will generate an upstream stream-id by
+ * doing an URI query on the element and in the worst case just uses
+ * a random number. Source elements that don't implement the URI
+ * handler interface should ideally generate a unique, deterministic
+ * stream-id manually instead.
+ *
+ * Returns: A stream-id for @pad. g_free() after usage.
+ */
+gchar *
+gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
+ const gchar * stream_id, va_list var_args)
+{
+ gchar *expanded = NULL, *new_stream_id;
+
+ if (stream_id)
+ expanded = g_strdup_vprintf (stream_id, var_args);
+
+ new_stream_id = gst_pad_create_stream_id_internal (pad, parent, expanded);
+
+ g_free (expanded);
+
+ return new_stream_id;
+}
+
+/**
* gst_pad_create_stream_id_printf:
* @pad: A source #GstPad
* @parent: Parent #GstElement of @pad
@@ -3736,7 +3750,7 @@ gchar *
gst_pad_create_stream_id (GstPad * pad, GstElement * parent,
const gchar * stream_id)
{
- return gst_pad_create_stream_id_printf (pad, parent, stream_id, NULL);
+ return gst_pad_create_stream_id_internal (pad, parent, stream_id);
}
/**
diff --git a/gst/gstutils.h b/gst/gstutils.h
index 153080775..b9097b1c3 100644
--- a/gst/gstutils.h
+++ b/gst/gstutils.h
@@ -934,9 +934,9 @@ gboolean gst_pad_peer_query_convert (GstPad *pad, GstFormat
GstCaps * gst_pad_peer_query_caps (GstPad * pad, GstCaps *filter);
gboolean gst_pad_peer_query_accept_caps (GstPad * pad, GstCaps *caps);
-gchar * gst_pad_create_stream_id (GstPad * pad, GstElement * parent, const gchar *stream_id);
-gchar * gst_pad_create_stream_id_printf (GstPad * pad, GstElement * parent, const gchar *stream_id, ...);
-gchar * gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent, const gchar *stream_id, va_list var_args);
+gchar * gst_pad_create_stream_id (GstPad * pad, GstElement * parent, const gchar *stream_id) G_GNUC_MALLOC;
+gchar * gst_pad_create_stream_id_printf (GstPad * pad, GstElement * parent, const gchar *stream_id, ...) G_GNUC_PRINTF (3, 4) G_GNUC_MALLOC;
+gchar * gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent, const gchar *stream_id, va_list var_args) G_GNUC_PRINTF (3, 0) G_GNUC_MALLOC;
gchar * gst_pad_get_stream_id (GstPad * pad);