From: fennecdjay Date: Tue, 5 Mar 2019 23:08:39 +0000 (+0100) Subject: :art: Update arguments X-Git-Tag: nightly~2753^2~28 X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=d1eca6d070a371e8d48165ee2dd532a10fe3b754;p=gwion.git :art: Update arguments --- diff --git a/Makefile b/Makefile index f7f4b108..07923bdc 100644 --- a/Makefile +++ b/Makefile @@ -20,10 +20,6 @@ parse_src := $(wildcard src/parse/*.c) util_src := $(wildcard src/util/*.c) emit_src := $(wildcard src/emit/*.c) opt_src := $(wildcard opt/*.c) -drvr_src := src/drvr/driver.c - -# add libraries -drvr_src +=src/drvr/dummy.c # add boolean ifeq (${USE_GWCOV}, 1) @@ -64,9 +60,8 @@ emit_obj := $(emit_src:.c=.o) oo_obj := $(oo_src:.c=.o) vm_obj := $(vm_src:.c=.o) util_obj := $(util_src:.c=.o) -drvr_obj := $(drvr_src:.c=.o) -GW_OBJ=${src_obj} ${ast_obj} ${parse_obj} ${emit_obj} ${oo_obj} ${drvr_obj} ${vm_obj} ${util_obj} ${lib_obj} +GW_OBJ=${src_obj} ${ast_obj} ${parse_obj} ${emit_obj} ${oo_obj} ${vm_obj} ${util_obj} ${lib_obj} ifeq ($(shell uname), Linux) LDFLAGS+=-lrt diff --git a/src/arg.c b/src/arg.c index ac7f4391..fb255a2b 100644 --- a/src/arg.c +++ b/src/arg.c @@ -22,31 +22,16 @@ ANN void arg_release(Arg* arg) { } static const struct option long_option[] = { - { "add", 0, NULL, '+' }, - { "rem", 0, NULL, 'z' }, { "pludir", 0, NULL, 'P' }, - { "quit", 0, NULL, 'q' }, { "driver", 1, NULL, 'd' }, - { "card", 1, NULL, 'c' }, - { "backend", 1, NULL, 'b' }, { "sr", 1, NULL, 's' }, - { "name", 1, NULL, 'n' }, - { "raw", 0, NULL, 'r' }, - { "host", 1, NULL, 'h' }, - { "port", 1, NULL, 'p' }, - { "rate", 1, NULL, 'r' }, - { "alone", 1, NULL, 'a' }, { "in", 1, NULL, 'i' }, { "out", 1, NULL, 'o' }, -// { "bufsize", 1, NULL, 'b' }, -// { "bufnum", 1, NULL, 'n' }, { "loop", 1, NULL, 'l' }, - { "format", 1, NULL, 'l' }, { "help", 0, NULL, '?' }, { "version", 0, NULL, 'v' }, { "config", 0, NULL, 'C' }, { "module", 0, NULL, 'm' }, - /* { "status" , 0, NULL, '%' },*/ { NULL, 0, NULL, 0 } }; @@ -57,23 +42,10 @@ static const char usage[] = "\t--help, -?\t : this help\n" "\t--version -v\t : this help\n" "VM options:\n" -"\t--add, -+\t : add file\n" -"\t--rem, --\t : remove shred\n" "\t--plugdir, -P\t : add a plugin directory\n" -"\t--quit -q\t : quit the vm\n" -"\t--profile -G\t : enter profile mode (if enabled)\n" "DRIVER options:\n" "\t--driver -d\t : set the driver (one of: alsa jack soundio portaudio file dummy silent raw)\n" "\t--sr -s\t : set samplerate\n" -"\t--bufnum -n\t : set number of buffers\n" -"\t--bufsize -b\t : set size of buffers\n" -"\t--chan -g\t : (global) channel number\n" -"\t--in -i\t : number of input channel\n" -"\t--out -o\t : number of output channel\n" -"\t--card -c\t : card identifier or output file (depending on driver)\n" -"\t--raw -r\t <0 or 1> : enable raw mode (file and soundio only)\n" -"\t--format -f\t : soundio format (one of: S8 U8 S16 U16 S24 U24 S32 U32 F32 F64)\n" -"\t--backend -e\t : soundio backend (one of: jack pulse alsa core wasapi dummy)\n" ; ANN static void arg_add(Arg* arg) { @@ -93,14 +65,6 @@ ANN static void arg_add(Arg* arg) { ANN static void arg_drvr(DriverInfo* di, const int i) { switch(i) { -// case 'c': -// di->card = optarg; - break; -// case 'g': -// di->chan = (m_uint)strtol(optarg, NULL, 10); -// di->in = (m_uint)strtol(optarg, NULL, 10); -// di->out = (m_uint)strtol(optarg, NULL, 10); -// break; case 'i': di->in = (m_uint)strtol(optarg, NULL, 10); break; @@ -113,21 +77,6 @@ ANN static void arg_drvr(DriverInfo* di, const int i) { case 'd': di->arg = optarg; break; - case 'f': - select_format(di, optarg); - break; - case 'e': - select_backend(di, optarg); - break; -// case 'r': -// di->raw = 1; -// break; -// case 'n': -// di->bufnum = (m_uint)strtol(optarg, NULL, 10); -// break; -// case 'b': -// di->bufsize = (m_uint)strtol(optarg, NULL, 10); -// break; default: gw_err("Unknown argument '%c'\n", i); } @@ -137,7 +86,7 @@ ANN uint parse_args(Arg* arg, DriverInfo* di) { uint quit = 0; int i, index; arg_init(arg); - while((i = getopt_long(arg->argc, arg->argv, "?vqh:p:i:o:n:b:e:s:d:l:g:-:rc:f:m:P:C ", + while((i = getopt_long(arg->argc, arg->argv, "?vl:i:o:s:d:m:P:C ", long_option, &index)) != -1) { switch(i) { case '?': @@ -147,9 +96,6 @@ ANN uint parse_args(Arg* arg, DriverInfo* di) { gw_err("CFLAGS: %s\nLDFLAGS: %s\n", CFLAGS, LDFLAGS); exit(1); break; - case 'q': - quit = 1; - break; case 'l': arg->loop = strtol(optarg, NULL, 10) > 0 ? 1 : -1; break; diff --git a/src/drvr/driver.c b/src/drvr/driver.c deleted file mode 100644 index 2939f570..00000000 --- a/src/drvr/driver.c +++ /dev/null @@ -1,170 +0,0 @@ -#include -#include -#include -#include -#include -#include "gwion_util.h" -#include "gwion_ast.h" -#include "oo.h" -#include "vm.h" -#include "driver.h" - -ANN struct BBQ_* new_bbq(DriverInfo* di) { - struct BBQ_* bbq = (struct BBQ_*)xcalloc(1, sizeof(struct BBQ_)); - bbq->out = (m_float*)xcalloc(di->out, SZ_FLOAT); - bbq->in = (m_float*)xcalloc(di->in, SZ_FLOAT); - bbq->n_in = (uint8_t)di->in; - bbq->sr = di->sr; - bbq->n_out = (uint8_t)di->out; - return bbq; -} - -void select_driver(DriverInfo* di, const m_str d) { - if(!strcmp("dummy", d)) - di->func = dummy_driver; - else if(!strcmp("silent", d)) - di->func = silent_driver; - -#ifdef HAVE_SNDFILE - else if(!strcmp("sndfile", d)) { - di->func = sndfile_driver; - di->card = "/tmp/gwion"; - } -#endif - -#ifdef HAVE_SPA - else if(!strcmp("spa", d)) { - di->func = spa_driver; - di->card = "/tmp/gwion"; - } -#endif - -#ifdef HAVE_ALSA - else if(!strcmp("alsa", d)) { - di->func = alsa_driver; - di->format = SND_PCM_FORMAT_FLOAT64; - di->card = "default"; - } -#endif - -#ifdef HAVE_JACK - else if(!strcmp("jack", d)) { - di->func = jack_driver; -// di->card = "default"; - } -#endif - -#ifdef HAVE_SOUNDIO - else if(!strcmp("soundio", d)) { - di->func = sio_driver; - di->backend = SoundIoBackendNone; - di->format = SoundIoFormatFloat32NE; -// di->card = "default"; - } -#endif - -#ifdef HAVE_PORTAUDIO - else if(!strcmp("portaudio", d)) { - di->func = pa_driver; - di->format = paFloat32; - di->card = "default"; - } -#endif -#ifdef HAVE_PULSE - else if(!strcmp("pulse", d)) { - di->func = pulse_driver; -// di->format = paFloat32; -// di->card = "default"; - } -#endif -#ifdef HAVE_PLOT - else if(!strcmp("plot", d)) - di->func = plot_driver; -#endif -#ifdef HAVE_SLES - else if(!strcmp("sles", d)) - di->func = sles_driver; -#endif - else - gw_err("invalid driver specified. using default.\n"); -} - -void select_backend(DriverInfo* di __attribute__((unused)), const m_str d __attribute__((unused))) { -#ifdef HAVE_SOUNDIO - if(!strcmp("dummy", d)) - di->backend = SoundIoBackendDummy; - else if(!strcmp("alsa", d)) - di->backend = SoundIoBackendAlsa; - else if(!strcmp("jack", d)) - di->backend = SoundIoBackendJack; - else if(!strcmp("pulse", d)) - di->backend = SoundIoBackendPulseAudio; - else if(!strcmp("core", d)) - di->backend = SoundIoBackendCoreAudio; - else if(!strcmp("wasapi", d)) - di->backend = SoundIoBackendWasapi; -#endif -} - -void select_format(DriverInfo* di __attribute__((unused)), const m_str d __attribute__((unused))) { -#ifdef HAVE_ALSA - if(di->func == alsa_driver) { - if(!strcmp("S8", d)) - di->format = SND_PCM_FORMAT_S8; - if(!strcmp("S16", d)) - di->format = SND_PCM_FORMAT_S16; - else if(!strcmp("U16", d)) - di->format = SND_PCM_FORMAT_U16; - else if(!strcmp("S24", d)) - di->format = SND_PCM_FORMAT_S24; - else if(!strcmp("U24", d)) - di->format = SND_PCM_FORMAT_U24; - else if(!strcmp("S32", d)) - di->format = SND_PCM_FORMAT_S32; - else if(!strcmp("U32", d)) - di->format = SND_PCM_FORMAT_U32; - else if(!strcmp("F32", d)) - di->format = SND_PCM_FORMAT_FLOAT; - else if(!strcmp("F64", d)) - di->format = SND_PCM_FORMAT_FLOAT64; - } -#endif - -#ifdef HAVE_SOUNDIO - if(di->func == sio_driver) { - if(!strcmp("S16", d)) - di->format = SoundIoFormatS16NE; - else if(!strcmp("U16", d)) - di->format = SoundIoFormatU16NE; - else if(!strcmp("S24", d)) - di->format = SoundIoFormatS24NE; - else if(!strcmp("U24", d)) - di->format = SoundIoFormatU24NE; - else if(!strcmp("S32", d)) - di->format = SoundIoFormatS32NE; - else if(!strcmp("U32", d)) - di->format = SoundIoFormatU32NE; - else if(!strcmp("F32", d)) - di->format = SoundIoFormatFloat32NE; - else if(!strcmp("F64", d)) - di->format = SoundIoFormatFloat64NE; - } -#endif - -#ifdef HAVE_PORTAUDIO - if(di->func == pa_driver) { - if(!strcmp("S32", d) || !strcmp("U32", d)) - di->format = paInt32; - if(!strcmp("S24", d) || !strcmp("U24", d)) - di->format = paInt24; - if(!strcmp("S16", d) || !strcmp("U16", d)) - di->format = paInt16; - else if(!strcmp("S8", d)) - di->format = paInt8; - else if(!strcmp("U8", d)) - di->format = paUInt8; -// paCustomFormat - } -#endif - -} diff --git a/src/drvr/dummy.c b/src/vm/driver.c similarity index 52% rename from src/drvr/dummy.c rename to src/vm/driver.c index 888a83c9..22360bbd 100644 --- a/src/drvr/dummy.c +++ b/src/vm/driver.c @@ -1,24 +1,28 @@ #include -#include +#include +#include +#include +#include #include "gwion_util.h" #include "gwion_ast.h" #include "oo.h" #include "vm.h" #include "driver.h" -static void dummy_run(VM* vm, DriverInfo* di) { - while(vm->is_running) { - di->run(vm); - ++vm->bbq->pos; - } +ANN struct BBQ_* new_bbq(DriverInfo* di) { + struct BBQ_* bbq = (struct BBQ_*)xcalloc(1, sizeof(struct BBQ_)); + bbq->out = (m_float*)xcalloc(di->out, SZ_FLOAT); + bbq->in = (m_float*)xcalloc(di->in, SZ_FLOAT); + bbq->n_in = (uint8_t)di->in; + bbq->sr = di->sr; + bbq->n_out = (uint8_t)di->out; + return bbq; } -static void silent_run(VM* vm, DriverInfo* di) { - const uint timer = 1000000 / vm->bbq->sr; +static void dummy_run(VM* vm, DriverInfo* di) { while(vm->is_running) { di->run(vm); ++vm->bbq->pos; - usleep(timer); } } @@ -26,11 +30,6 @@ static m_bool dummy_ini(VM* vm __attribute__((unused)), DriverInfo* di __attribu return GW_OK; } -void silent_driver(Driver* d) { - d->ini = dummy_ini; - d->run = silent_run; -} - void dummy_driver(Driver* d) { d->ini = dummy_ini; d->run = dummy_run;