ao, shairport: fix option parsing
- don't push unrecognised args to the audio driver - get ao to parse from first argument - ao checks for unrecognised options
This commit is contained in:
+6
-1
@@ -47,7 +47,9 @@ static int init(int argc, char **argv) {
|
||||
int driver = ao_default_driver_id();
|
||||
ao_option *ao_opts = NULL;
|
||||
|
||||
optind = 0;
|
||||
optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour
|
||||
argv--; // so we shift the arguments to satisfy getopt()
|
||||
argc++;
|
||||
// some platforms apparently require optreset = 1; - which?
|
||||
int opt;
|
||||
char *mid;
|
||||
@@ -80,6 +82,9 @@ static int init(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
die("Invalid audio argument: %s", argv[optind]);
|
||||
|
||||
ao_sample_format fmt;
|
||||
memset(&fmt, 0, sizeof(fmt));
|
||||
|
||||
|
||||
@@ -88,6 +88,9 @@ void usage(char *progname) {
|
||||
}
|
||||
|
||||
int parse_options(int argc, char **argv) {
|
||||
// prevent unrecognised arguments from being shunted to the audio driver
|
||||
setenv("POSIXLY_CORRECT", "", 1);
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "+hdvp:a:o:b:B:E:")) > 0) {
|
||||
switch (opt) {
|
||||
|
||||
Reference in New Issue
Block a user