From: Tim-Philipp Müller Date: Wed, 13 Feb 2013 16:52:13 +0000 (+0000) Subject: message: accept NULL error argument in gst_message_parse_{error,warning,info} X-Git-Tag: 1.1.1~269 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5fc34add2560ad3d6abd970b0b8cbe4f35e00f2a;p=platform%2Fupstream%2Fgstreamer.git message: accept NULL error argument in gst_message_parse_{error,warning,info} And simplify code a bit while at it. https://bugzilla.gnome.org/show_bug.cgi?id=693704 --- diff --git a/gst/gstmessage.c b/gst/gstmessage.c index de3ffdd..3916bbf 100644 --- a/gst/gstmessage.c +++ b/gst/gstmessage.c @@ -1314,28 +1314,12 @@ gst_message_parse_structure_change (GstMessage * message, void gst_message_parse_error (GstMessage * message, GError ** gerror, gchar ** debug) { - const GValue *error_gvalue; - GError *error_val; - GstStructure *structure; - g_return_if_fail (GST_IS_MESSAGE (message)); g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_ERROR); - structure = GST_MESSAGE_STRUCTURE (message); - error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR)); - g_return_if_fail (error_gvalue != NULL); - g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_ERROR); - - error_val = (GError *) g_value_get_boxed (error_gvalue); - if (error_val) - *gerror = g_error_copy (error_val); - else - *gerror = NULL; - - if (debug) - *debug = - g_value_dup_string (gst_structure_id_get_value (structure, - GST_QUARK (DEBUG))); + gst_structure_id_get (GST_MESSAGE_STRUCTURE (message), + GST_QUARK (GERROR), G_TYPE_ERROR, gerror, + GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL); } /** @@ -1354,28 +1338,12 @@ void gst_message_parse_warning (GstMessage * message, GError ** gerror, gchar ** debug) { - const GValue *error_gvalue; - GError *error_val; - GstStructure *structure; - g_return_if_fail (GST_IS_MESSAGE (message)); g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_WARNING); - structure = GST_MESSAGE_STRUCTURE (message); - error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR)); - g_return_if_fail (error_gvalue != NULL); - g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_ERROR); - - error_val = (GError *) g_value_get_boxed (error_gvalue); - if (error_val) - *gerror = g_error_copy (error_val); - else - *gerror = NULL; - - if (debug) - *debug = - g_value_dup_string (gst_structure_id_get_value (structure, - GST_QUARK (DEBUG))); + gst_structure_id_get (GST_MESSAGE_STRUCTURE (message), + GST_QUARK (GERROR), G_TYPE_ERROR, gerror, + GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL); } /** @@ -1393,28 +1361,12 @@ gst_message_parse_warning (GstMessage * message, GError ** gerror, void gst_message_parse_info (GstMessage * message, GError ** gerror, gchar ** debug) { - const GValue *error_gvalue; - GError *error_val; - GstStructure *structure; - g_return_if_fail (GST_IS_MESSAGE (message)); g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO); - structure = GST_MESSAGE_STRUCTURE (message); - error_gvalue = gst_structure_id_get_value (structure, GST_QUARK (GERROR)); - g_return_if_fail (error_gvalue != NULL); - g_return_if_fail (G_VALUE_TYPE (error_gvalue) == G_TYPE_ERROR); - - error_val = (GError *) g_value_get_boxed (error_gvalue); - if (error_val) - *gerror = g_error_copy (error_val); - else - *gerror = NULL; - - if (debug) - *debug = - g_value_dup_string (gst_structure_id_get_value (structure, - GST_QUARK (DEBUG))); + gst_structure_id_get (GST_MESSAGE_STRUCTURE (message), + GST_QUARK (GERROR), G_TYPE_ERROR, gerror, + GST_QUARK (DEBUG), G_TYPE_STRING, debug, NULL); } /** diff --git a/tests/check/gst/gstmessage.c b/tests/check/gst/gstmessage.c index c33a72b..94d5cdd 100644 --- a/tests/check/gst/gstmessage.c +++ b/tests/check/gst/gstmessage.c @@ -54,6 +54,8 @@ GST_START_TEST (test_parsing) error = NULL; debug = NULL; + gst_message_parse_error (message, NULL, NULL); + gst_message_parse_error (message, &error, &debug); fail_if (error == NULL); fail_if (debug == NULL); @@ -82,6 +84,8 @@ GST_START_TEST (test_parsing) warning = NULL; debug = NULL; + gst_message_parse_warning (message, NULL, NULL); + gst_message_parse_warning (message, &warning, &debug); fail_if (warning == NULL); fail_if (debug == NULL); @@ -96,6 +100,33 @@ GST_START_TEST (test_parsing) } /* GST_MESSAGE_INFO */ { + GError *info = NULL; + gchar *debug; + + info = g_error_new (domain, 10, "test info"); + fail_if (info == NULL); + message = gst_message_new_info (NULL, info, "info string"); + fail_if (message == NULL); + fail_unless (GST_MESSAGE_TYPE (message) == GST_MESSAGE_INFO); + fail_unless (GST_MESSAGE_SRC (message) == NULL); + + g_error_free (info); + info = NULL; + debug = NULL; + + gst_message_parse_info (message, NULL, NULL); + + gst_message_parse_info (message, &info, &debug); + fail_if (info == NULL); + fail_if (debug == NULL); + fail_unless (strcmp (info->message, "test info") == 0); + fail_unless (info->domain == domain); + fail_unless (info->code == 10); + fail_unless (strcmp (debug, "info string") == 0); + + gst_message_unref (message); + g_error_free (info); + g_free (debug); } /* GST_MESSAGE_TAG */ {