X-Git-Url: https://git.distorted.org.uk/~mdw/jog/blobdiff_plain/2ec1e6937048636ec6761c3a76c5bf9544278601..08b95ae46c249ee9652c8645ac1701165fea28de:/main.c diff --git a/main.c b/main.c index 6855a86..f78746d 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,6 @@ /* -*-c-*- * - * $Id: main.c,v 1.1 2002/01/25 19:34:45 mdw Exp $ + * $Id: main.c,v 1.3 2002/02/02 19:21:53 mdw Exp $ * * Main program * @@ -26,16 +26,12 @@ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/*----- Revision history --------------------------------------------------* - * - * $Log: main.c,v $ - * Revision 1.1 2002/01/25 19:34:45 mdw - * Initial revision - * - */ - /*----- Header files ------------------------------------------------------*/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include #include #include @@ -51,7 +47,9 @@ #include #include +#include "au.h" #include "err.h" +#include "jog.h" #include "rxglue.h" #include "txport.h" #include "tx-serial-unix.h" @@ -63,6 +61,7 @@ static int sigtab[] = { SIGINT, SIGQUIT, SIGTERM, SIGHUP, -1 }; static void tidy(void) { txsu_shutdown(); + au_shutdown(); } static void sigtidy(int sig) @@ -76,7 +75,10 @@ static void sigtidy(int sig) static void usage(FILE *fp) { - pquis(fp, "Usage: $ [-t TRANSPORT] [-f FILE] [-c CONFIG] SCRIPT [ARG]\n"); + pquis(fp, "\ +Usage: $ [-t TRANSPORT] [-f FILE] [-c CONFIG] [-a AUDIR] [-x SIZE]\n\ + SCRIPT ARG...\n\ +"); } static void version(FILE *fp) @@ -99,6 +101,9 @@ Options provided:\n\ -t, --transport=NAME Use transport type NAME.\n\ -f, --tx-file=FILE Communicate using the named FILE.\n\ -c, --tx-config=CONFIG Use CONFIG as transport configuration.\n\ +\n\ +-a, --audio=DIR Set directory containing audio samples.\n\ +-x, --cache-max=SIZE Maximum size for audio sample cache.\n\ ", fp); } @@ -110,6 +115,8 @@ int main(int argc, char *argv[]) unsigned f = 0; int rc = 0; int i; + const char *audir = 0; + size_t aumax = AU_CACHEMAX; #define f_bogus 1u @@ -120,7 +127,7 @@ int main(int argc, char *argv[]) err_init(); rx_init(); - trace_on(stderr, 0u); + T( trace_on(stderr, 0u); ) if ((txname = getenv("JOGTX")) != 0) ; else @@ -149,12 +156,38 @@ int main(int argc, char *argv[]) { "txfile", OPTF_ARGREQ, 0, 'f' }, { "file", OPTF_ARGREQ, 0, 'f' }, + /* --- Audio configuration stuff --- */ + + { "audio-directory", + OPTF_ARGREQ, 0, 'a' }, + { "audio-cache-max", + OPTF_ARGREQ, 0, 'x' }, + { "cache-max", + OPTF_ARGREQ, 0, 'x' }, + + /* --- Debugging stuff --- */ + +#ifndef NTRACE + { "trace", OPTF_ARGREQ, 0, 'T' }, +#endif + /* --- End marker --- */ { 0, 0, 0, 0 } }; - i = mdwopt(argc, argv, "hvut:c:f:", opt, 0, 0, 0); +#ifndef NTRACE + static const trace_opt tropt[] = { + { 'x', T_TX, "transport layer" }, + { 's', T_TXSYS, "low-level transport" }, + { 'a', T_AU, "audio subsystem" }, + { 'y', T_AUSYS, "system-specific audio" }, + { 'A', T_ALL, "all of the above" }, + { 0, 0, 0 } + }; +#endif + + i = mdwopt(argc, argv, "hvu" "t:c:f:" "a:x:" T("T:"), opt, 0, 0, 0); if (i < 0) break; @@ -184,6 +217,23 @@ int main(int argc, char *argv[]) txfile = optarg; break; + /* --- Audio configuration stuff --- */ + + case 'a': + audir = optarg; + break; + case 'x': + aumax = strtoul(optarg, 0, 0); + break; + + /* --- Tracing --- */ + +#ifndef NTRACE + case 'T': + trace_level(traceopt(tropt, optarg, tracing(), 0)); + break; +#endif + /* --- Errors --- */ default: @@ -192,11 +242,12 @@ int main(int argc, char *argv[]) } } - if ((f & f_bogus) || (optind != argc - 1 && optind != argc - 2)) { + if ((f & f_bogus) || optind > argc - 1) { usage(stderr); exit(EXIT_FAILURE); } + au_init(audir, aumax); rc = rx_runfile(argv[optind], argc - optind - 1, (const char *const *)argv + optind + 1); return (rc ? EXIT_FAILURE : 0);