MediaPipelineImpl: Fix NULL dereferencing, simplify code
@@ -36,42 +36,25 @@ void
MediaPipelineImpl::log_bus_issue(GstBin *bin, GstMessage *msg,
gboolean is_error)
{
- gchar *type;
+ GstDebugLevel log_level = is_error ? GST_LEVEL_ERROR : GST_LEVEL_WARNING;
+
GError *err = NULL;
gchar *dbg_info = NULL;
- gchar *dot_name;
- GstDebugLevel log_level;
-
gst_message_parse_error (msg, &err, &dbg_info);
- if (is_error) {
- log_level = GST_LEVEL_ERROR;
- type = g_strdup ("error");
- } else {
- log_level = GST_LEVEL_WARNING;
- type = g_strdup ("warning");
- }
-
GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, log_level, NULL,
- "Element '%s': Bus %s %d: %s", GST_ELEMENT_NAME (bin), type, err->code,
+ "Element '%s' bus code %d: %s", GST_OBJECT_NAME (msg->src), err->code,
err->message);
GST_CAT_LEVEL_LOG (GST_CAT_DEFAULT, log_level, NULL,
"Debugging info: %s", ((dbg_info) ? dbg_info : "None"));
- std::string errorMessage;
- if (err) {
- errorMessage = std::string (err->message);
- }
+ std::string errorMessage (err->message);
if (dbg_info) {
- errorMessage += " -> " + std::string (dbg_info);
- }
- try {
- gint code = 0;
-
- if (err) {
- code = err->code;
+ errorMessage += " (" + std::string (dbg_info) + ")";
}
+ try {
+ gint code = err->code;
Error error (shared_from_this(), errorMessage, code,
"UNEXPECTED_PIPELINE_ERROR");
@@ -79,14 +62,12 @@ MediaPipelineImpl::log_bus_issue(GstBin *bin, GstMessage *msg,
} catch (std::bad_weak_ptr &e) {
}
- g_error_free (err);
- g_free (dbg_info);
-
- dot_name = g_strdup_printf ("%s_bus_%s", GST_DEFAULT_NAME, type);
+ gchar *dot_name = g_strdup_printf ("%s_bus_%d", GST_DEFAULT_NAME, err->code);
GST_DEBUG_BIN_TO_DOT_FILE_WITH_TS (bin, GST_DEBUG_GRAPH_SHOW_ALL, dot_name);
g_free(dot_name);
- g_free(type);
+ g_error_free (err);
+ g_free (dbg_info);
}
void
