[Xfce4-commits] <xfce4-mixer:gber/improvements> Add runtime debugging mode

Guido Berhoerster noreply at xfce.org
Fri Sep 21 17:18:26 CEST 2012


Updating branch refs/heads/gber/improvements
         to f89cede2c468f683f3c99593f320073d99f19c1e (commit)
       from 3805dc99e574268e8c08a42e6b1d129025fed21c (commit)

commit f89cede2c468f683f3c99593f320073d99f19c1e
Author: Guido Berhoerster <guido+xfce at berhoerster.name>
Date:   Fri Sep 21 12:00:36 2012 +0200

    Add runtime debugging mode
    
    Add a runtime debugging mode to both the mixer application and the panel plugin
    which will print additional diagnostic output.
    Add a "--debug" command line option to xfce4-mixer which will activate the
    debugging mode.
    Make the panel plugin look for the PANEL_DEBUG environment variable containing
    "mixer" in order to enable the debugging mode.
    Add custom xfce_mixer_debug() function for printing debugging output.
    Replace DBG() macro with xfce_mixer_debug().
    Print relevant GStreamer data on startup when in debugging mode.
    Add "--version command" line option to xfce4-mixer which will print the
    version.

 NEWS                             |    1 +
 README                           |   14 ++
 libxfce4mixer/Makefile.am        |    4 +-
 libxfce4mixer/libxfce4mixer.c    |    4 +
 libxfce4mixer/libxfce4mixer.h    |    1 +
 libxfce4mixer/xfce-mixer-debug.c |  259 ++++++++++++++++++++++++++++++++++++++
 libxfce4mixer/xfce-mixer-debug.h |   53 ++++++++
 panel-plugin/xfce-mixer-plugin.c |   14 ++
 xfce4-mixer/Makefile.am          |    1 +
 xfce4-mixer/main.c               |   58 +++++++--
 xfce4-mixer/xfce-mixer.c         |    8 +-
 11 files changed, 398 insertions(+), 19 deletions(-)

diff --git a/NEWS b/NEWS
index 2286c16..b9aa6b5 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,7 @@
   xfce4-mixer, make the panel plugin context menu entry for running the mixer
   more meaningful.
 - Add tooltips to scale widgets in the mixer.
+- Add runtime debugging mode to both the mixer and the panel plugin.
 
 
 4.8.0
diff --git a/README b/README
index 98df7c5..48756f0 100644
--- a/README
+++ b/README
@@ -5,6 +5,19 @@ This package contains a volume control application based on GStreamer
 0.10 written to conceptually fit into the Xfce desktop environment. It
 includes a plugin for the Xfce panel.
 
+
+Debugging
+---------
+
+Both the mixer application and the panel plugin have a builtin debugging mode
+which will print additional diagnostic output useful for bug reports. For
+xfce4-mixer it can be activated by specifying the --debug command line option,
+diagnostic messages will be printed to stderr. For the panel plugin, please
+follow the instructions at http://docs.xfce.org/xfce/xfce4-panel/debugging and
+set the PANEL_DEBUG environment variable to "mixer", the disgnostic output can
+then be found in the log file corresponding to the plugin.
+
+
 Known Problems with GStreamer
 -----------------------------
 
@@ -13,3 +26,4 @@ Known Problems with GStreamer
     Debian or Ubuntu system and you're using ALSA then installing 
     gstreamer0.10-alsa should fix it. On OpenBSD installing 
     gst-plugins-good might help.
+
diff --git a/libxfce4mixer/Makefile.am b/libxfce4mixer/Makefile.am
index 8f44cd4..4107cdd 100644
--- a/libxfce4mixer/Makefile.am
+++ b/libxfce4mixer/Makefile.am
@@ -15,7 +15,9 @@ libxfce4mixer_la_SOURCES =						\
 	xfce-mixer-track-type.h						\
 	xfce-mixer-track-type.c						\
 	xfce-mixer-preferences.h					\
-	xfce-mixer-preferences.c
+	xfce-mixer-preferences.c					\
+	xfce-mixer-debug.h						\
+	xfce-mixer-debug.c
 
 libxfce4mixer_la_CFLAGS = 						\
 	-I$(top_builddir)						\
diff --git a/libxfce4mixer/libxfce4mixer.c b/libxfce4mixer/libxfce4mixer.c
index 6ca9466..da0bfe4 100644
--- a/libxfce4mixer/libxfce4mixer.c
+++ b/libxfce4mixer/libxfce4mixer.c
@@ -23,6 +23,10 @@
 #include <config.h>
 #endif
 
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
 #include <glib.h>
 
 #include <dbus/dbus-glib.h>
diff --git a/libxfce4mixer/libxfce4mixer.h b/libxfce4mixer/libxfce4mixer.h
index 473817c..8628df9 100644
--- a/libxfce4mixer/libxfce4mixer.h
+++ b/libxfce4mixer/libxfce4mixer.h
@@ -32,6 +32,7 @@
 #include "xfce-mixer-card-combo.h"
 #include "xfce-mixer-track-combo.h"
 #include "xfce-mixer-track-type.h"
+#include "xfce-mixer-debug.h"
 
 #define XFCE_MIXER_TYPE_VALUE_ARRAY (xfce_mixer_value_array_get_type ())
 
diff --git a/libxfce4mixer/xfce-mixer-debug.c b/libxfce4mixer/xfce-mixer-debug.c
new file mode 100644
index 0000000..a5b6205
--- /dev/null
+++ b/libxfce4mixer/xfce-mixer-debug.c
@@ -0,0 +1,259 @@
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2012 Guido Berhoerster <guido+xfce at berhoerster.name>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include <glib.h>
+#include <stdarg.h>
+
+#include <gst/gst.h>
+
+#include "libxfce4mixer.h"
+#include "xfce-mixer-debug.h"
+
+
+
+#if !GLIB_CHECK_VERSION (2,32,0)
+static void
+xfce_mixer_dummy_log_handler (const gchar    *log_domain,
+                              GLogLevelFlags  log_level,
+                              const gchar    *message,
+                              gpointer        unused_data)
+{
+  /* Swallow all messages */
+}
+#endif
+
+
+
+void
+xfce_mixer_debug_init (const gchar *log_domain,
+                       gboolean     debug_mode)
+{
+  /*
+   * glib >= 2.32 only shows debug messages if G_MESSAGES_DEBUG contains the
+   * log domain or "all", earlier glib version always show debugging output
+   */
+#if GLIB_CHECK_VERSION (2,32,0)
+  const gchar        *debug_env;
+  gint                i = 0;
+  const gchar        *debug_env_new_array[] = { NULL, NULL, NULL, NULL };
+  gchar              *debug_env_new;
+
+  if (debug_mode)
+    {
+      debug_env = g_getenv ("G_MESSAGES_DEBUG");
+
+      if (log_domain == NULL)
+        debug_env_new_array[i++] = "all";
+      else
+        {
+          if (debug_env != NULL)
+            debug_env_new_array[i++] = debug_env;
+          if (debug_env == NULL || strstr (debug_env, log_domain) == NULL)
+            debug_env_new_array[i++] = log_domain;
+          if (debug_env == NULL || strstr (debug_env, G_LOG_DOMAIN) == NULL)
+            debug_env_new_array[i++] = G_LOG_DOMAIN;
+        }
+      debug_env_new = g_strjoinv (" ", debug_env_new_array);
+      g_setenv ("G_MESSAGES_DEBUG", debug_env_new, TRUE);
+    }
+#else
+  if (!debug_mode)
+    {
+      g_log_set_handler (log_domain, G_LOG_LEVEL_DEBUG, xfce4_mixer_dummy_log_handler, NULL);
+      g_log_set_handler (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, xfce4_mixer_dummy_log_handler, NULL);
+    }
+#endif /* GLIB_CHECK_VERSION (2,32,0) */
+}
+
+
+
+void
+xfce_mixer_debug_real (const gchar *log_domain,
+                       const gchar *file,
+                       const gchar *func,
+                       gint line,
+                       const gchar *format, ...)
+{
+  va_list args;
+  gchar *prefixed_format;
+
+  va_start (args, format);
+  prefixed_format = g_strdup_printf ("[%s:%d %s]: %s", file, line, func, format);
+  g_logv (log_domain, G_LOG_LEVEL_DEBUG, prefixed_format, args);
+  va_end (args);
+
+  g_free (prefixed_format);
+}
+
+
+
+void
+xfce_mixer_dump_gst_data (void)
+{
+  GString            *result;
+  GList              *cards;
+  GList              *cards_iter;
+  GstElementFactory  *factory;
+  GstElement         *card;
+  gchar              *card_device_name = NULL;
+  GstElement         *default_card;
+  GstMixerTrack      *default_track;
+  GList              *default_track_list;
+  const gchar        *card_long_name;
+  GstMixerFlags       mixer_flags;
+  const GList        *tracks;
+  const GList        *tracks_iter;
+  GstMixerTrack      *track;
+  gchar              *track_label;
+  gchar              *track_untranslated_label;
+  guint               track_index;
+  GstMixerTrackFlags  track_flags;
+  gint                i;
+  gint                max_volume;
+  gint                min_volume;
+  gint               *volumes;
+  GList              *options;
+  GList              *options_iter;
+
+  result = g_string_sized_new (4096);
+  g_string_assign (result, "GStreamer data:\n");
+
+  cards = xfce_mixer_get_cards ();
+  default_card = xfce_mixer_get_default_card ();
+
+  if (cards == NULL || g_list_length (cards) == 0)
+    g_string_append (result, "\tno mixers found\n");
+
+  for (cards_iter = g_list_first (cards); cards_iter != NULL; cards_iter = g_list_next (cards_iter))
+    {
+      card = GST_ELEMENT (cards_iter->data);
+
+      factory = gst_element_get_factory (card);
+
+      default_track = xfce_mixer_get_default_track (card);
+      default_track_list = xfce_mixer_get_default_track_list (card);
+
+      g_string_append (result, "\tmixer:\n");
+
+      if (g_object_class_find_property (G_OBJECT_GET_CLASS (G_OBJECT (card)), "device-name"))
+        g_object_get (G_OBJECT (card), "device-name", &card_device_name, NULL);
+      g_string_append_printf (result, "\t\tdevice-name: \"%s\"\n", (card_device_name != NULL) ? card_device_name : "<unknown>");
+
+      card_long_name = gst_element_factory_get_longname (factory);
+      g_string_append_printf (result, "\t\tlongname: \"%s\"\n", (card_long_name != NULL) ? card_long_name : "<unknown>");
+
+      mixer_flags = gst_mixer_get_mixer_flags (GST_MIXER (card));
+      if (mixer_flags & GST_MIXER_FLAG_AUTO_NOTIFICATIONS)
+        g_string_append (result, "\t\tflag: GST_MIXER_FLAG_AUTO_NOTIFICATIONS\n");
+      if (mixer_flags & GST_MIXER_FLAG_HAS_WHITELIST)
+        g_string_append (result, "\t\tflag: GST_MIXER_FLAG_HAS_WHITELIST\n");
+
+      if (card == default_card)
+        g_string_append (result, "\t\txfce4-mixer default mixer\n");
+
+      tracks = gst_mixer_list_tracks (GST_MIXER (card));
+      for (tracks_iter = tracks; tracks_iter != NULL; tracks_iter = g_list_next (tracks_iter))
+        {
+          track = GST_MIXER_TRACK (tracks_iter->data);
+
+          g_string_append (result, "\t\ttrack:\n");
+
+          g_object_get (G_OBJECT (track), "label", &track_label,
+                        "untranslated-label", &track_untranslated_label,
+                        "index", &track_index,
+                        "flags", &track_flags,
+                        "max-volume", &max_volume,
+                        "min-volume", &min_volume, NULL);
+          g_string_append_printf (result, "\t\t\tlabel: \"%s\"\n", track_label);
+          g_string_append_printf (result, "\t\t\tindex: %d\n", track_index);
+          g_string_append_printf (result, "\t\t\tuntranslated-label: \"%s\"\n", track_untranslated_label);
+
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_INPUT))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_INPUT\n");
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_OUTPUT))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_OUTPUT\n");
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MUTE))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_MUTE\n");
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_RECORD))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_RECORD\n");
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_MASTER))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_MASTER\n");
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_NO_RECORD))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_NO_RECORD\n");
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_NO_MUTE))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_NO_MUTE\n");
+          if (GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_WHITELIST))
+            g_string_append (result, "\t\t\tflag: GST_MIXER_TRACK_WHITELIST\n");
+
+          if (GST_IS_MIXER_OPTIONS (track))
+            {
+              g_string_append (result, "\t\t\ttype: options\n");
+              options = gst_mixer_options_get_values (GST_MIXER_OPTIONS (track));
+              for (options_iter = options; options_iter != NULL; options_iter = g_list_next (options_iter))
+                g_string_append_printf (result, "\t\t\tvalue: \"%s\"\n", (gchar *) options_iter->data);
+              g_string_append_printf (result, "\t\t\tcurrent value: \"%s\"\n", gst_mixer_get_option (GST_MIXER (card), GST_MIXER_OPTIONS (track)));
+            }
+          else if (track->num_channels == 0)
+            g_string_append (result, "\t\t\ttype: switch\n");
+          else
+            {
+              g_string_append (result, "\t\t\ttype: volume\n");
+              g_string_append_printf (result, "\t\t\tchannels: %d\n", track->num_channels);
+              g_string_append_printf (result, "\t\t\tmin-volume: %d\n", min_volume);
+              g_string_append_printf (result, "\t\t\tmax-volume: %d\n", max_volume);
+
+              volumes = g_new0 (gint, track->num_channels);
+              gst_mixer_get_volume (GST_MIXER (card), track, volumes);
+              for (i = 0; i < track->num_channels; ++i)
+                g_string_append_printf (result, "\t\t\tvolume channel[%d]: %d\n", i, volumes[i]);
+
+              g_free (volumes);
+            }
+
+          if (track == default_track)
+            g_string_append (result, "\t\t\txfce4-mixer-plugin default track\n");
+
+          if (g_list_find (default_track_list, track) != NULL)
+            g_string_append (result, "\t\t\txfce4-mixer default mixer\n");
+
+          g_free (track_label);
+          g_free (track_untranslated_label);
+        }
+
+      g_free (card_device_name);
+      card_device_name = NULL;
+    }
+
+  /* Remove trailing newline */
+  if (result->str[result->len - 1] == '\n')
+    result->str[--result->len] = '\0';
+  g_debug ("%s", result->str);
+
+  g_string_free (result, TRUE);
+}
+
diff --git a/libxfce4mixer/xfce-mixer-debug.h b/libxfce4mixer/xfce-mixer-debug.h
new file mode 100644
index 0000000..87a2e57
--- /dev/null
+++ b/libxfce4mixer/xfce-mixer-debug.h
@@ -0,0 +1,53 @@
+/* vi:set expandtab sw=2 sts=2: */
+/*-
+ * Copyright (c) 2012 Guido Berhoerster <guido+xfce at berhoerster.name>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, 
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __XFCE_MIXER_DEBUG_H__
+#define __XFCE_MIXER_DEBUG_H__
+
+#include <glib.h>
+#include <stdarg.h>
+
+G_BEGIN_DECLS
+
+#if __STDC_VERSION__ < 199901L
+#if __GNUC__ >= 2
+#define __func__ __FUNCTION__
+#else
+#define __func__ "<unknown>"
+#endif /* __GNUC__ >= 2 */
+#endif /* __STDC_VERSION__ < 199901L */
+
+#define xfce_mixer_debug(...) xfce_mixer_debug_real (G_LOG_DOMAIN, __FILE__, __func__, __LINE__, __VA_ARGS__)
+
+void xfce_mixer_debug_init        (const gchar    *log_domain,
+                                   gboolean        debug_mode);
+void xfce_mixer_debug_real        (const gchar    *log_domain,
+                                   const gchar    *file,
+                                   const gchar    *func,
+                                   gint            line,
+                                   const gchar    *format, ...);
+void xfce_mixer_dump_gst_data     (void);
+
+
+
+G_END_DECLS
+
+#endif /* !__XFCE_MIXER_DEBUG_H__ */
+
diff --git a/panel-plugin/xfce-mixer-plugin.c b/panel-plugin/xfce-mixer-plugin.c
index ec7e60b..7cf0a62 100644
--- a/panel-plugin/xfce-mixer-plugin.c
+++ b/panel-plugin/xfce-mixer-plugin.c
@@ -197,6 +197,9 @@ xfce_mixer_plugin_class_init (XfceMixerPluginClass *klass)
 static void
 xfce_mixer_plugin_init (XfceMixerPlugin *mixer_plugin)
 {
+  gboolean     debug_mode = FALSE;
+  const gchar *panel_debug_env;
+
   /* Initialize some of the plugin variables */
   mixer_plugin->card = NULL;
   mixer_plugin->track = NULL;
@@ -222,6 +225,17 @@ xfce_mixer_plugin_init (XfceMixerPlugin *mixer_plugin)
   /* Initialize libkeybinder */
   keybinder_init ();
 
+  /* Enable debug level logging if PANEL_DEBUG contains G_LOG_DOMAIN */
+  panel_debug_env = g_getenv ("PANEL_DEBUG");
+  if (panel_debug_env != NULL && strstr (panel_debug_env, G_LOG_DOMAIN) != NULL)
+    debug_mode = TRUE;
+  xfce_mixer_debug_init (G_LOG_DOMAIN, debug_mode);
+
+  xfce_mixer_debug ("mixer plugin version " VERSION " starting up");
+
+  if (debug_mode)
+    xfce_mixer_dump_gst_data ();
+
   /* Create container for the plugin */
   mixer_plugin->hvbox = GTK_WIDGET (xfce_hvbox_new (GTK_ORIENTATION_HORIZONTAL, FALSE, 0));
   xfce_panel_plugin_add_action_widget (XFCE_PANEL_PLUGIN (mixer_plugin), mixer_plugin->hvbox);
diff --git a/xfce4-mixer/Makefile.am b/xfce4-mixer/Makefile.am
index e5a45f0..8735737 100644
--- a/xfce4-mixer/Makefile.am
+++ b/xfce4-mixer/Makefile.am
@@ -24,6 +24,7 @@ xfce4_mixer_CFLAGS = 							\
 	-DPACKAGE_LOCALE_DIR=\"$(localedir)\"				\
 	-DDATADIR=\"$(datadir)\"					\
 	-DMIXER_DATADIR=\"$(pkgdatadir)\"				\
+	-DG_LOG_DOMAIN=\"xfce4-mixer\"					\
 	$(GLIB_CFLAGS)							\
 	$(GTK_CFLAGS)							\
 	$(UNIQUE_CFLAGS)						\
diff --git a/xfce4-mixer/main.c b/xfce4-mixer/main.c
index 5a65f0b..0c5026c 100644
--- a/xfce4-mixer/main.c
+++ b/xfce4-mixer/main.c
@@ -75,9 +75,18 @@ int
 main (int    argc,
       char **argv)
 {
-  UniqueApp     *app;
-  GtkWidget     *window;
-  GError        *error = NULL;
+  UniqueApp          *app;
+  GtkWidget          *window;
+  GError             *error = NULL;
+  gboolean            debug_mode = FALSE;
+  gboolean            show_version = FALSE;
+  GOptionContext     *option_context;
+  GOptionEntry        option_entries[] =
+  {
+    { "debug", 'd', 0, G_OPTION_ARG_NONE, &debug_mode, N_("Enable debugging output"), NULL },
+    { "version", 'V', 0, G_OPTION_ARG_NONE, &show_version, N_("Show version and exit"), NULL },
+    { NULL, 0, 0, 0, NULL, NULL, NULL }
+  };
 
   /* Setup translation domain */
   xfce_textdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR, "UTF-8");
@@ -86,32 +95,45 @@ main (int    argc,
   if (G_LIKELY (!g_thread_supported ()))
     g_thread_init (NULL);
 
-  /* Set debug level */
-#ifdef G_ENABLE_DEBUG
-  g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING);
-#endif
-
   /* Set application name */
   g_set_application_name (_("Audio Mixer"));
 
-  /* Initialize GTK+ */
-  gtk_init (&argc, &argv);
+  /* Parse commandline options */
+  option_context = g_option_context_new ("- Adjust volume levels");
+  g_option_context_add_main_entries (option_context, option_entries, GETTEXT_PACKAGE);
+  g_option_context_add_group (option_context, gtk_get_option_group (FALSE));
+  g_option_context_add_group (option_context, gst_init_get_option_group ());
+  g_option_context_parse (option_context, &argc, &argv, &error);
+  g_option_context_free (option_context);
+  if (error != NULL)
+    {
+      g_printerr ("xfce4-mixer: %s\n", error->message);
+
+      return EXIT_FAILURE;
+    }
+
+  if (show_version)
+    {
+      g_print ("xfce4-mixer " VERSION "\n");
+
+      return EXIT_SUCCESS;
+    }
+
+  /* Initialize GTK+ fully */
+  gtk_init (NULL, NULL);
 
   /* Initialize Xfconf */
   if (G_UNLIKELY (!xfconf_init (&error)))
     {
       if (G_LIKELY (error != NULL))
         {
-          g_print (_("Failed to initialize xfconf: %s"), error->message);
+          g_printerr (_("xfce4-mixer: Failed to initialize xfconf: %s\n"), error->message);
           g_error_free (error);
         }
 
       return EXIT_FAILURE;
     }
 
-  /* Initialize GStreamer */
-  gst_init (&argc, &argv);
-
   /* Initialize the mixer library */
   xfce_mixer_init ();
 
@@ -130,6 +152,14 @@ main (int    argc,
       return EXIT_FAILURE;
     }
 
+  /* Initialize debugging code */
+  xfce_mixer_debug_init (G_LOG_DOMAIN, debug_mode);
+
+  xfce_mixer_debug ("xfce4-mixer version " VERSION " starting up");
+
+  if (debug_mode)
+    xfce_mixer_dump_gst_data ();
+
   /* Create unique application */
   app = unique_app_new ("org.xfce.xfce4-mixer", NULL);
   if (unique_app_is_running (app))
diff --git a/xfce4-mixer/xfce-mixer.c b/xfce4-mixer/xfce-mixer.c
index f61a87e..159a610 100644
--- a/xfce4-mixer/xfce-mixer.c
+++ b/xfce4-mixer/xfce-mixer.c
@@ -418,7 +418,7 @@ xfce_mixer_bus_message (GstBus     *bus,
     {
       gst_mixer_message_parse_mute_toggled (message, &track, &muted);
       g_object_get (track, "label", &label, NULL);
-      DBG ("Track '%s' was %s", label, muted ? "muted" : "unmuted");
+      xfce_mixer_debug ("Track '%s' was %s", label, muted ? "muted" : "unmuted");
       widget = g_hash_table_lookup (mixer->widgets, label);
       g_free (label);
 
@@ -431,7 +431,7 @@ xfce_mixer_bus_message (GstBus     *bus,
     {
       gst_mixer_message_parse_record_toggled (message, &track, &record);
       g_object_get (track, "label", &label, NULL);
-      DBG ("Recording on track '%s' was %s", label, record ? "turned on" : "turned off");
+      xfce_mixer_debug ("Recording on track '%s' was %s", label, record ? "turned on" : "turned off");
       widget = g_hash_table_lookup (mixer->widgets, label);
       g_free (label);
 
@@ -444,7 +444,7 @@ xfce_mixer_bus_message (GstBus     *bus,
     {
       gst_mixer_message_parse_volume_changed (message, &track, &volumes, &num_channels);
       g_object_get (track, "label", &label, NULL);
-      DBG ("Volume on track '%s' changed to %i", label, volumes[0]);
+      xfce_mixer_debug ("Volume on track '%s' changed to %i", label, volumes[0]);
       widget = g_hash_table_lookup (mixer->widgets, label);
       g_free (label);
 
@@ -455,7 +455,7 @@ xfce_mixer_bus_message (GstBus     *bus,
     {
       gst_mixer_message_parse_option_changed (message, &options, &option);
       g_object_get (GST_MIXER_TRACK (options), "label", &label, NULL);
-      DBG ("Option '%s' was set to '%s'", label, option);
+      xfce_mixer_debug ("Option '%s' was set to '%s'", label, option);
       widget = g_hash_table_lookup (mixer->widgets, label);
       g_free (label);
 


More information about the Xfce4-commits mailing list