Commit 68545393 authored by Mans Rullgard's avatar Mans Rullgard

mqascan: allow multiple input files

parent 4b894f66
......@@ -319,15 +319,60 @@ static void write_metadata(const char *file)
}
fclose(md);
free(metadata);
metadata = NULL;
metadata_frags = 0;
}
int main(int argc, char **argv)
static int scan_file(const char *name, int start)
{
SNDFILE *file;
SF_INFO fmt;
bitnum = 0;
abspos = 0;
memset(&fmt, 0, sizeof(fmt));
file = sf_open(name, SFM_READ, &fmt);
if (!file) {
fprintf(stderr, "%s: %s\n", name, sf_strerror(NULL));
return -1;
}
if (fmt.channels != 2) {
fprintf(stderr, "%s: %d channels not allowed\n",
name, fmt.channels);
return -1;
}
if (start)
sf_seek(file, start, SEEK_SET);
print_verbosity(verbosity);
if (!setjmp(eofjmp)) {
init_bits_sf(&br, file, 8);
br.msb = 0;
br.get_bits_cb = get_bits_cb;
br.eof_cb = eof_cb;
find_mqa_sync(&br);
scan_mqa(&br);
}
print_end();
sf_close(file);
return 0;
}
int main(int argc, char **argv)
{
const char *mdfile = NULL;
int start = 0;
int opt;
int i;
while ((opt = getopt(argc, argv, "1m:M:p:s:v")) != -1) {
switch (opt) {
......@@ -361,38 +406,15 @@ int main(int argc, char **argv)
if (argc < 1)
return 1;
memset(&fmt, 0, sizeof(fmt));
file = sf_open(argv[0], SFM_READ, &fmt);
if (!file) {
fprintf(stderr, "%s: %s\n", argv[0], sf_strerror(NULL));
return 1;
}
if (fmt.channels != 2) {
fprintf(stderr, "Only 2 channels supported\n");
return 1;
}
if (start)
sf_seek(file, start, SEEK_SET);
print_verbosity(verbosity);
for (i = 0; i < argc; i++) {
if (argc > 1)
printf("%s\n", argv[i]);
if (!setjmp(eofjmp)) {
init_bits_sf(&br, file, 8);
br.msb = 0;
br.get_bits_cb = get_bits_cb;
br.eof_cb = eof_cb;
find_mqa_sync(&br);
scan_mqa(&br);
}
print_end();
scan_file(argv[i], start);
if (metadata && mdfile)
write_metadata(mdfile);
sf_close(file);
}
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment