[Xfce4-commits] [apps/xfburn] 02/03: Improve error message when a plugin is missing.

noreply at xfce.org noreply at xfce.org
Mon Jul 20 01:47:37 CEST 2015


This is an automated email from the git hooks/post-receive script.

squisher pushed a commit to branch master
in repository apps/xfburn.

commit 4a8b89cd45db09f54f7215efae862f5634191d9a
Author: David Mohr <david at mcbf.net>
Date:   Sun Jul 19 17:42:13 2015 -0600

    Improve error message when a plugin is missing.
    
    Partially based on Gnome's tracker-extract, thanks!
---
 xfburn/xfburn-transcoder-gst.c |   72 ++++++++++++++++++++++++++++++++++------
 1 file changed, 61 insertions(+), 11 deletions(-)

diff --git a/xfburn/xfburn-transcoder-gst.c b/xfburn/xfburn-transcoder-gst.c
index b7c4d98..36394fd 100644
--- a/xfburn/xfburn-transcoder-gst.c
+++ b/xfburn/xfburn-transcoder-gst.c
@@ -520,7 +520,8 @@ bus_call (GstBus *bus, GstMessage *msg, gpointer data)
     }
 
     case GST_MESSAGE_ELEMENT: {
-      /* TODO: is this code still reachable now that identification uses the discoverer API? */
+      /* This should not happen now that the discoverer API is used to identify songs.
+       * Shouldn't hurt to keep around though. */
       if (gst_is_missing_plugin_message (msg)) {
           recreate_pipeline (trans);
 
@@ -649,6 +650,26 @@ cb_handoff (GstElement *element, GstBuffer *buffer, gpointer data)
 
 #endif
 
+static gchar *
+get_discoverer_required_plugins_message (GstDiscovererInfo *info)
+{
+  GString *str;
+  gchar **plugins;
+  gchar *plugins_str;
+
+  plugins = (gchar **) gst_discoverer_info_get_missing_elements_installer_details (info);
+
+  if (g_strv_length(plugins) == 0) {
+    str = g_string_new ("No information available on which plugin is required.");
+  } else {
+    str = g_string_new("Required plugins: ");
+    plugins_str = g_strjoinv (", ", plugins);
+    g_string_append (str, plugins_str);
+    g_free (plugins_str);
+  }
+
+  return g_string_free (str, FALSE);
+}
 
 static gboolean
 get_audio_track (XfburnTranscoder *trans, XfburnAudioTrack *atrack, GError **error)
@@ -670,19 +691,48 @@ get_audio_track (XfburnTranscoder *trans, XfburnAudioTrack *atrack, GError **err
   info = gst_discoverer_discover_uri(priv->discoverer, uri, error);
   g_free(uri);
 
-  if (*error != NULL) {
-      return FALSE;
+  if (info == NULL) {
+    if (error && *error == NULL) {
+        DBG ("no info and no error");
+        g_set_error (error, XFBURN_ERROR, XFBURN_ERROR_GST_DISCOVERER,
+                    _("An error occurred while identifying '%s' with gstreamer"), atrack->inputfile);
+    }
+    return FALSE;
   }
 
-  if ((result = gst_discoverer_info_get_result(info)) != GST_DISCOVERER_OK) {
-    gst_discoverer_info_unref(info);
-    DBG ("gst discoverer said %d", result);
-    /* TODO: improve error messages */
-    //recreate_pipeline (tgst);
-    g_set_error (error, XFBURN_ERROR, XFBURN_ERROR_GST_DISCOVERER,
-                _("An error occurred while identifying '%s' with gstreamer"), atrack->inputfile);
-    return FALSE;
+  result = gst_discoverer_info_get_result(info);
+  switch (result) {
+    case GST_DISCOVERER_MISSING_PLUGINS:
+      g_clear_error (error);
+      /*
+      g_set_error (error, XFBURN_ERROR, XFBURN_ERROR_GST_DISCOVERER,
+                  _("%s: %s"), atrack->inputfile, get_discoverer_required_plugins_message (info));
+      */
+      // the message is pretty useless, so print it only on the console, and create our own instead.
+      DBG ("%s", get_discoverer_required_plugins_message (info));
+      g_set_error (error, XFBURN_ERROR, XFBURN_ERROR_MISSING_PLUGIN,
+                   _("A plugin is missing.\n"
+                     "\n"
+                     "You do not have a decoder installed to handle this file.\n"
+                     "Probably you need to look at the gst-plugins-* packages\n"
+                     "for the necessary plugins.\n"));
+      gst_discoverer_info_unref(info);
+      return FALSE;
+    case GST_DISCOVERER_OK:
+      break;
+    default:
+      gst_discoverer_info_unref(info);
+      DBG ("gst discoverer said %d", result);
+      /* TODO: improve error messages */
+      //recreate_pipeline (tgst);
+      if (error && *error == NULL)
+        g_set_error (error, XFBURN_ERROR, XFBURN_ERROR_GST_DISCOVERER,
+                     _("An error occurred while identifying '%s' with gstreamer"), atrack->inputfile);
+      else
+        g_prefix_error (error, "%s: ", atrack->inputfile);
+      return FALSE;
   }
+
   priv->gst_done = FALSE;
 
   priv->duration = gst_discoverer_info_get_duration(info);

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list