chiark / gitweb /
server/gstdecode.c: Add `-s' option to omit DisOrder's usual framing.
authorMark Wooding <mdw@distorted.org.uk>
Sun, 26 Nov 2017 19:30:41 +0000 (19:30 +0000)
committerMark Wooding <mdw@distorted.org.uk>
Wed, 29 Nov 2017 11:47:21 +0000 (11:47 +0000)
The result can be piped into something like

play -b16 -c2 -esigned-integer -r44100 -L -traw -

to verify that its output approximates decoded audio.

doc/disorder-gstdecode.8.in
server/gstdecode.c

index 61d7fd40af95f989fc2fef1512178c1e0c2cdd96..e3175c27bcbfb8a01c7b06c472d7f48e62287fb1 100644 (file)
@@ -21,6 +21,7 @@
 disorder-gstdecode \- DisOrder audio decoder using GStreamer
 .SH SYNOPSIS
 .B disorder\-gstdecode
+.RB [ \-s ]
 .RB [ -c
 .IR CONFIGFILE ]
 .RB [ \-d
@@ -105,6 +106,11 @@ This can be \fBoff\fR to not bother with ReplayGain at all,
 (so that the volume level sounds consistent
 when playing an entire album).
 The default is \fBalbum\fR.
+.TP
+.B \-\-stream\fR, \fB\-s
+Write a stream of raw samples to the output,
+instead of including DisOrder's usual framing.
+This is useful for testing the program on its own.
 .SH "SEE ALSO"
 .BR disorderd (8),
 .BR disorder_config (5)
index 10884a43056076f91973e759e302fd8a4a47fcce..93cde8500d678da4755e7afb1f5487256d949195 100644 (file)
@@ -51,6 +51,8 @@ static const char *file;
 static GstAppSink *appsink;
 static GstElement *pipeline;
 static GMainLoop *loop;
+static unsigned flags = 0;
+#define f_stream 1u
 
 #define MODES(_) _("off", OFF) _("track", TRACK) _("album", ALBUM)
 enum {
@@ -338,7 +340,7 @@ static GstFlowReturn cb_buffer(GstAppSink *sink, gpointer UNUSED u)
 
   /* Write out a frame of audio data. */
   hdr.nbytes = GST_BUFFER_SIZE(buf);
-  if(fwrite(&hdr, sizeof(hdr), 1, fp) != 1 ||
+  if((!(flags&f_stream) && fwrite(&hdr, sizeof(hdr), 1, fp) != 1) ||
      fwrite(GST_BUFFER_DATA(buf), 1, hdr.nbytes, fp) != hdr.nbytes)
     disorder_fatal(errno, "output");
 
@@ -419,6 +421,7 @@ static const struct option options[] = {
   { "noise-shape", required_argument, 0, 'n' },
   { "quality", required_argument, 0, 'q' },
   { "replay-gain", required_argument, 0, 'r' },
+  { "stream", no_argument, 0, 's' },
   { 0, 0, 0, 0 }
 };
 
@@ -437,6 +440,7 @@ static void help(void)
           "                                     `simple', `medium' or `high'\n"
           "  --quality QUAL, -q QUAL    Resampling quality: 0 poor, 10 good\n"
           "  --replay-gain MODE, -r MODE  MODE is `off', `track' or `album'\n"
+          "  --stream, -s               Output raw samples, without framing\n"
           "\n"
           "Alternative audio decoder for DisOrder.  Only intended to be\n"
           "used by speaker process, not for normal users.\n");
@@ -455,7 +459,7 @@ int main(int argc, char *argv[])
   if(!setlocale(LC_CTYPE, "")) disorder_fatal(errno, "calling setlocale");
 
   /* Parse command line. */
-  while((n = getopt_long(argc, argv, "hVc:d:f:n:q:r:", options, 0)) >= 0) {
+  while((n = getopt_long(argc, argv, "hVc:d:f:n:q:r:s", options, 0)) >= 0) {
     switch(n) {
     case 'h': help();
     case 'V': version("disorder-gstdecode");
@@ -465,6 +469,7 @@ int main(int argc, char *argv[])
     case 'n': shape = getenum("noise-shaping type", optarg, shapes); break;
     case 'q': quality = getint("resample quality", optarg, 0, 10); break;
     case 'r': mode = getenum("ReplayGain mode", optarg, modes); break;
+    case 's': flags |= f_stream; break;
     default: disorder_fatal(0, "invalid option");
     }
   }