[xmp] Add -n option for no sound output

Signed-off-by: Claudio Matsuoka <cmatsuoka@gmail.com>
master
Claudio Matsuoka 14 years ago
parent cf08b06dee
commit cda9e14c32
  1. 2
      src/Makefile
  2. 1
      src/common.h
  3. 5
      src/main.c
  4. 60
      src/options.c
  5. 40
      src/sound_null.c

@ -1,6 +1,6 @@
#SRC_OBJS = getopt.o getopt1.o options.o drivers.o main.o
SRC_OBJS = sound_alsa.o terminal.o info.o options.o main.o
SRC_OBJS = sound_null.o sound_alsa.o terminal.o info.o options.o main.o
SRC_DFILES = Makefile xmp.1 $(SRC_OBJS:.o=.c) common.h
SRC_PATH = src

@ -10,6 +10,7 @@ struct options {
int random; /* play in random order */
int load_only; /* load module and exit */
int verbose;
int silent; /* silent output */
char *out_file; /* output file name */
char *ins_path; /* instrument path */
char mute[XMP_MAX_CHANNELS];

@ -13,6 +13,7 @@
extern int optind;
extern struct sound_driver sound_alsa;
extern struct sound_driver sound_null;
struct sound_driver *sound = &sound_alsa;
@ -71,6 +72,10 @@ int main(int argc, char **argv)
shuffle(argc - optind + 1, &argv[optind - 1]);
}
if (options.silent) {
sound = &sound_null;
}
if (sound->init(44100, 2) < 0) {
fprintf(stderr, "%s: can't initialize sound\n", argv[0]);
exit(EXIT_FAILURE);

@ -129,38 +129,37 @@ static void usage(char *s)
" -v --verbose Verbose mode (incremental)\n");
}
static struct option lopt[] = {
{ "amplify", 1, 0, 'a' },
{ "bits", 1, 0, 'b' },
{ "driver", 1, 0, 'd' },
{ "frequency", 1, 0, 'f' },
{ "offset-bug-emulation", 0, 0, OPT_FX9BUG },
{ "help", 0, 0, 'h' },
{ "instrument-path", 1, 0, 'I' },
{ "load-only", 0, 0, OPT_LOADONLY },
{ "loop", 0, 0, 'l' },
{ "mono", 0, 0, 'm' },
{ "mute", 1, 0, 'M' },
{ "output-file", 1, 0, 'o' },
{ "pan", 1, 0, 'P' },
{ "quiet", 0, 0, 'q' },
{ "random", 0, 0, 'R' },
{ "solo", 1, 0, 'S' },
{ "start", 1, 0, 's' },
{ "stdout", 0, 0, 'c' },
{ "tempo", 1, 0, 'T' },
{ "time", 1, 0, 't' },
{ "unsigned", 0, 0, 'u' },
{ "version", 0, 0, 'V' },
{ "verbose", 0, 0, 'v' },
{ NULL, 0, 0, 0 }
};
void get_options(int argc, char **argv, struct options *options)
{
int optidx = 0;
#define OPTIONS "a:b:cD:d:f:hI:lM:mo:qRS:s:T:t:uVv"
static struct option lopt[] = {
{"amplify", 1, 0, 'a'},
{"bits", 1, 0, 'b'},
{"driver", 1, 0, 'd'},
{"frequency", 1, 0, 'f'},
{"offset-bug-emulation", 0, 0, OPT_FX9BUG},
{"help", 0, 0, 'h'},
{"instrument-path", 1, 0, 'I'},
{"load-only", 0, 0, OPT_LOADONLY},
{"loop", 0, 0, 'l'},
{"mono", 0, 0, 'm'},
{"mute", 1, 0, 'M'},
{"nocmd", 0, 0, OPT_NOCMD},
{"output-file", 1, 0, 'o'},
{"pan", 1, 0, 'P'},
{"quiet", 0, 0, 'q'},
{"random", 0, 0, 'R'},
{"solo", 1, 0, 'S'},
{"start", 1, 0, 's'},
{"stdout", 0, 0, 'c'},
{"tempo", 1, 0, 'T'},
{"time", 1, 0, 't'},
{"unsigned", 0, 0, 'u'},
{"version", 0, 0, 'V'},
{"verbose", 0, 0, 'v'},
{NULL, 0, 0, 0}
};
#define OPTIONS "a:b:cD:d:f:hI:lM:mno:qRS:s:T:t:uVv"
i = 0;
while ((o = getopt_long(argc, argv, OPTIONS, lopt, &optidx)) != -1) {
switch (o) {
@ -201,6 +200,9 @@ void get_options(int argc, char **argv, struct options *options)
case 'm':
options->format |= XMP_FORMAT_MONO;
break;
case 'n':
options->silent = 1;
break;
case 'o':
options->out_file = optarg;
if (strlen(optarg) >= 4 &&

@ -0,0 +1,40 @@
#include <stdlib.h>
#include "sound.h"
static int init(int sampling_rate, int channels)
{
}
static void play(void *b, int i)
{
}
static void deinit()
{
}
static void flush()
{
}
static void onpause()
{
}
static void onresume()
{
}
struct sound_driver sound_null = {
"null",
"No output",
NULL,
init,
deinit,
play,
flush,
onpause,
onresume
};
Loading…
Cancel
Save