From ff56519f303d58db08eadf5e36356afcc27234fc Mon Sep 17 00:00:00 2001 Message-Id: From: Mark Wooding Date: Sun, 26 Nov 2017 19:30:41 +0000 Subject: [PATCH 1/1] server/gstdecode.c: Add `-s' option to omit DisOrder's usual framing. Organization: Straylight/Edgeware From: Mark Wooding 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 | 6 ++++++ server/gstdecode.c | 9 +++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/disorder-gstdecode.8.in b/doc/disorder-gstdecode.8.in index 61d7fd4..e3175c2 100644 --- a/doc/disorder-gstdecode.8.in +++ b/doc/disorder-gstdecode.8.in @@ -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) diff --git a/server/gstdecode.c b/server/gstdecode.c index 10884a4..93cde85 100644 --- a/server/gstdecode.c +++ b/server/gstdecode.c @@ -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"); } } -- [mdw]