summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2014-09-19 18:29:54 +0100
committerTim-Philipp Müller <tim@centricular.com>2014-09-19 18:29:54 +0100
commit87cef8befca2e3b97070b49dd07d869f75e8cbe2 (patch)
treee9c0c53be078f0079d39d9726ee383187c8c3e0b /tools
parent3ecb8bea22182bd79e34ede48cb16c78c40a8118 (diff)
gst-play: add --quiet option to suppress output
Diffstat (limited to 'tools')
-rw-r--r--tools/gst-play.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/tools/gst-play.c b/tools/gst-play.c
index c467439e4..6bcf7365b 100644
--- a/tools/gst-play.c
+++ b/tools/gst-play.c
@@ -34,6 +34,8 @@
#include <stdio.h>
#include <string.h>
+#include <glib/gprintf.h>
+
#include "gst-play-kb.h"
#define VOLUME_STEPS 20
@@ -65,6 +67,8 @@ typedef struct
gboolean gapless;
} GstPlay;
+static gboolean quiet = FALSE;
+
static gboolean play_bus_msg (GstBus * bus, GstMessage * msg, gpointer data);
static gboolean play_next (GstPlay * play);
static gboolean play_prev (GstPlay * play);
@@ -73,6 +77,30 @@ static void play_about_to_finish (GstElement * playbin, gpointer user_data);
static void play_reset (GstPlay * play);
static void play_set_relative_volume (GstPlay * play, gdouble volume_step);
+static void
+gst_play_printf (const gchar * format, ...)
+{
+ gchar *str = NULL;
+ va_list args;
+ int len;
+
+ if (quiet)
+ return;
+
+ va_start (args, format);
+
+ len = g_vasprintf (&str, format, args);
+
+ va_end (args);
+
+ if (len > 0 && str != NULL)
+ g_print ("%s", str);
+
+ g_free (str);
+}
+
+#define g_print gst_play_printf
+
static GstPlay *
play_new (gchar ** uris, const gchar * audio_sink, const gchar * video_sink,
gboolean gapless, gdouble initial_volume)
@@ -676,6 +704,8 @@ main (int argc, char **argv)
N_("Volume"), NULL},
{"playlist", 0, 0, G_OPTION_ARG_FILENAME, &playlist_file,
N_("Playlist file containing input media files"), NULL},
+ {"quiet", 'q', 0, G_OPTION_ARG_NONE, &quiet,
+ N_("Do not print any output (apart from errors)"), NULL},
{G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_FILENAME_ARRAY, &filenames, NULL},
{NULL}
};