ref: 5fce40be10e904ddbc195b93bccfd212c3d91e73
parent: 91be46d3df5fd10ad8cb1cd815258e9bb762c2c0
author: robs <robs>
date: Sat Jan 13 14:00:17 EST 2007
Allow play to use ofile fopts.
--- a/src/sox.c
+++ b/src/sox.c
@@ -242,6 +242,8 @@
{
size_t i;
bool play = false, rec = false;
+ file_info_t fi = NULL;
+ struct file_info fi_none;
myname = argv[0];
atexit(cleanup);
@@ -259,8 +261,8 @@
/* Loop over arguments and filenames, stop when an effect name is
* found. */
while (optind < argc && !is_effect_name(argv[optind])) {
- file_info_t fi = make_file_info();
- struct file_info fi_none = *fi;
+ fi = make_file_info();
+ fi_none = *fi;
if (file_count >= MAX_FILES) {
st_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
@@ -273,44 +275,46 @@
fi->filetype = "null";
fi->filename = xstrdup("--");
} else {
- if (optind >= argc || is_effect_name(argv[optind])) {
- if (memcmp(fi, &fi_none, sizeof(fi_none)) != 0) /* fopts but no file */
- usage("missing filename"); /* No return */
- free(fi); /* No file opts and no filename, so that's okay */
- continue;
- }
+ if (optind >= argc || is_effect_name(argv[optind]))
+ break;
fi->filename = xstrdup(argv[optind++]);
}
file_opts[file_count++] = fi;
+ fi = NULL;
}
- if (rec) {
- file_info_t fo = make_file_info();
- st_size_t i;
+ if (play) {
+ file_info_t fo = fi? fi : make_file_info();
if (file_count >= MAX_FILES) {
st_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
exit(1);
}
- file_count++;
- for (i = 0; i < file_count; i++)
- file_opts[i + 1] = file_opts[i];
-
set_device(fo);
- file_opts[0] = fo;
+ file_opts[file_count++] = fo;
}
+ else if (fi) {
+ if (memcmp(fi, &fi_none, sizeof(*fi)) != 0) /* fopts but no file */
+ usage("missing filename"); /* No return */
+ free(fi); /* No file opts and no filename, so that's okay */
+ }
- if (play) {
+ if (rec) {
file_info_t fo = make_file_info();
+ st_size_t i;
if (file_count >= MAX_FILES) {
st_fail("Too many filenames; maximum is %d input files and 1 output file", MAX_INPUT_FILES);
exit(1);
}
+ file_count++;
+ for (i = 0; i < file_count; i++)
+ file_opts[i + 1] = file_opts[i];
+
set_device(fo);
- file_opts[file_count++] = fo;
+ file_opts[0] = fo;
}
/* Make sure we got at least the required # of input filenames */
@@ -450,7 +454,7 @@
int i; /* Needed since scanf %u allows negative numbers :( */
char dummy; /* To check for extraneous chars in optarg. */
- if (strcmp(argv[optind], "--") == 0) {
+ if (optind < argc && strcmp(argv[optind], "--") == 0) {
++optind;
return true; /* I.e. is null file. */
}
@@ -475,6 +479,10 @@
fi->signal.reverse_bytes = ST_IS_LITTLEENDIAN;
else if (!strcmp(optarg, "swap"))
fi->signal.reverse_bytes = true;
+ else {
+ st_fail("Endian type '%s' is not little|big|swap", optarg);
+ exit(1);
+ }
break;
case 3: