Blame SOURCES/add-quiet-option.txt

0617f0
diff -ru libcanberra-0.30/src/canberra-gtk-play.c libcanberra-0.30.new/src/canberra-gtk-play.c
0617f0
--- libcanberra-0.30/src/canberra-gtk-play.c	2012-09-25 02:21:07.000000000 +0200
0617f0
+++ libcanberra-0.30.new/src/canberra-gtk-play.c	2019-01-03 10:01:13.090177362 +0100
0617f0
@@ -33,6 +33,7 @@
0617f0
 static int ret = 0;
0617f0
 static ca_proplist *proplist = NULL;
0617f0
 static int n_loops = 1;
0617f0
+static gboolean quiet = FALSE;
0617f0
 
0617f0
 static void callback(ca_context *c, uint32_t id, int error, void *userdata);
0617f0
 
0617f0
@@ -51,7 +52,8 @@
0617f0
         r = ca_context_play_full(ca_gtk_context_get(), 1, proplist, callback, NULL);
0617f0
 
0617f0
         if (r < 0) {
0617f0
-                g_printerr("Failed to play sound: %s\n", ca_strerror(r));
0617f0
+                if (!quiet)
0617f0
+                        g_printerr("Failed to play sound: %s\n", ca_strerror(r));
0617f0
                 ret = 1;
0617f0
                 gtk_main_quit();
0617f0
         }
0617f0
@@ -62,7 +64,8 @@
0617f0
 static void callback(ca_context *c, uint32_t id, int error, void *userdata) {
0617f0
 
0617f0
         if (error < 0) {
0617f0
-                g_printerr("Failed to play sound (callback): %s\n", ca_strerror(error));
0617f0
+                if (!quiet)
0617f0
+                        g_printerr("Failed to play sound (callback): %s\n", ca_strerror(error));
0617f0
                 ret = 1;
0617f0
 
0617f0
         } else if (n_loops > 1) {
0617f0
@@ -128,6 +131,7 @@
0617f0
                 { "loop",          'l', 0, G_OPTION_ARG_INT,      &n_loops,                  "Loop how many times (detault: 1)", "INTEGER" },
0617f0
                 { "volume",        'V', 0, G_OPTION_ARG_STRING,   &volume,                   "A floating point dB value for the sample volume (ex: 0.0)", "STRING" },
0617f0
                 { "property",      0,   0, G_OPTION_ARG_CALLBACK, (void*) property_callback, "An arbitrary property", "STRING" },
0617f0
+                { "quiet",         'q', 0, G_OPTION_ARG_NONE,     &quiet,                    "Don't print error messages", NULL },
0617f0
                 { NULL, 0, 0, 0, NULL, NULL, NULL }
0617f0
         };
0617f0
 
0617f0
@@ -154,7 +158,8 @@
0617f0
         }
0617f0
 
0617f0
         if (!event_id && !filename) {
0617f0
-                g_printerr("No event id or file specified.\n");
0617f0
+                if (!quiet)
0617f0
+                        g_printerr("No event id or file specified.\n");
0617f0
                 return 1;
0617f0
         }
0617f0
 
0617f0
@@ -182,7 +187,8 @@
0617f0
         r = ca_context_play_full(ca_gtk_context_get(), 1, proplist, callback, NULL);
0617f0
 
0617f0
         if (r < 0) {
0617f0
-                g_printerr("Failed to play sound: %s\n", ca_strerror(r));
0617f0
+                if (!quiet)
0617f0
+                        g_printerr("Failed to play sound: %s\n", ca_strerror(r));
0617f0
                 ret = 1;
0617f0
                 goto finish;
0617f0
         }