From: fennecdjay Date: Tue, 5 Mar 2019 22:35:05 +0000 (+0100) Subject: :art: Try Alsa X-Git-Tag: nightly~2753^2~30 X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=508d9b538ebdc8c1d245b890d5375727c9d60d97;p=gwion.git :art: Try Alsa --- diff --git a/include/driver.h b/include/driver.h index 37759c99..758d0bf3 100644 --- a/include/driver.h +++ b/include/driver.h @@ -2,19 +2,12 @@ #define __DRIVER typedef struct driver_wrapper* Driver_; typedef struct containing_driver_info { - m_uint in, out; - m_uint chan; - uint sr; - m_uint bufsize; - m_uint bufnum; - m_str card; - m_uint backend; - m_uint format; + uint8_t in, out; + uint32_t sr; m_str arg; void (*func)(Driver_); void (*run)(const VM*); void* data; - unsigned raw : 1; } DriverInfo; diff --git a/include/plug.h b/include/plug.h index 0e18dfc4..2bebfc8f 100644 --- a/include/plug.h +++ b/include/plug.h @@ -26,5 +26,6 @@ void plug_end(const Gwion gwion); #define GWMODEND(a) ANN void GWMODEND_NAME(const Gwion gwion, void* self) #define GWDRIVER(a) ANN void GWDRIVER_NAME(struct driver_wrapper* d) -void plug_ini(const Gwion gwion, const Vector); +ANN void plug_ini(const Gwion gwion, const Vector); +ANN Vector split_args(const m_str str); #endif diff --git a/include/vm.h b/include/vm.h index d8a4c874..44e057f3 100644 --- a/include/vm.h +++ b/include/vm.h @@ -19,8 +19,8 @@ struct BBQ_ { m_float* in; m_float* out; uint32_t sr; // int 32 - uint8_t nchan; uint8_t n_in; + uint8_t n_out; }; typedef struct Shreduler_* Shreduler; diff --git a/src/arg.c b/src/arg.c index 749733bd..ac7f4391 100644 --- a/src/arg.c +++ b/src/arg.c @@ -38,8 +38,8 @@ static const struct option long_option[] = { { "alone", 1, NULL, 'a' }, { "in", 1, NULL, 'i' }, { "out", 1, NULL, 'o' }, - { "bufsize", 1, NULL, 'b' }, - { "bufnum", 1, NULL, 'n' }, +// { "bufsize", 1, NULL, 'b' }, +// { "bufnum", 1, NULL, 'n' }, { "loop", 1, NULL, 'l' }, { "format", 1, NULL, 'l' }, { "help", 0, NULL, '?' }, @@ -93,14 +93,14 @@ 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 '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; @@ -119,15 +119,15 @@ ANN static void arg_drvr(DriverInfo* di, const int i) { 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; +// 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); } diff --git a/src/drvr/driver.c b/src/drvr/driver.c index fe299a63..2939f570 100644 --- a/src/drvr/driver.c +++ b/src/drvr/driver.c @@ -15,7 +15,7 @@ ANN struct BBQ_* new_bbq(DriverInfo* di) { bbq->in = (m_float*)xcalloc(di->in, SZ_FLOAT); bbq->n_in = (uint8_t)di->in; bbq->sr = di->sr; - bbq->nchan = (uint8_t)di->chan; + bbq->n_out = (uint8_t)di->out; return bbq; } diff --git a/src/gwion.c b/src/gwion.c index 9594284a..eda2402a 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -50,8 +50,9 @@ ANN m_bool gwion_audio(const Gwion gwion, DriverInfo* di) { } di->func(gwion->driver); VM* vm = gwion->vm; - return gwion->driver->ini(vm, di) > 0 && - (vm->bbq = new_bbq(di)); + CHECK_BB(gwion->driver->ini(vm, di)); + vm->bbq = new_bbq(di); + return GW_OK; } ANN m_bool gwion_engine(const Gwion gwion) { diff --git a/src/lib/ugen.c b/src/lib/ugen.c index 8e84e1b2..0a0da187 100644 --- a/src/lib/ugen.c +++ b/src/lib/ugen.c @@ -312,7 +312,7 @@ static GWION_IMPORT(global_ugens) { const VM* vm = gwi_vm(gwi); struct ugen_importer hole = { vm, compute_mono, "blackhole", 1, NULL }; add_ugen(gwi, &hole); - struct ugen_importer dac = { vm, dac_tick, "dac", vm->bbq->nchan, NULL }; + struct ugen_importer dac = { vm, dac_tick, "dac", vm->bbq->n_out, NULL }; add_ugen(gwi, &dac); struct ugen_importer adc = { vm, adc_tick, "adc", vm->bbq->n_in, NULL }; add_ugen(gwi, &adc); diff --git a/src/main.c b/src/main.c index a52b01c9..eb8d347b 100644 --- a/src/main.c +++ b/src/main.c @@ -17,8 +17,8 @@ static void sig(int unused __attribute__((unused))) { int main(int argc, char** argv) { Arg arg = { .argc = argc, .argv=argv, .loop=-1 }; - DriverInfo di = { .in=2, .out=2, .chan=2, .sr=48000, .bufsize=256, - .bufnum=3, .card="default:CARD=CODEC", .func=D_FUNC, .run=vm_run }; + DriverInfo di = { .in=2, .out=2, /* .chan=2, */ .sr=48000, /* .bufsize=256, + .bufnum=3, .card="default:CARD=CODEC",*/ .func=D_FUNC, .run=vm_run }; if(parse_args(&arg, &di)) { arg_release(&arg); return 0; @@ -26,7 +26,7 @@ int main(int argc, char** argv) { gwion_init(&gwion, &arg.lib); signal(SIGINT, sig); signal(SIGTERM, sig); - if(gwion_audio(&gwion, &di) && gwion_engine(&gwion)) { + if(gwion_audio(&gwion, &di) > 0 && gwion_engine(&gwion)) { plug_ini(&gwion, &arg.mod); for(m_uint i = 0; i < vector_size(&arg.add); i++) compile_filename(&gwion, (m_str)vector_at(&arg.add, i)); diff --git a/src/plug.c b/src/plug.c index 7e657403..e1c2e296 100644 --- a/src/plug.c +++ b/src/plug.c @@ -52,8 +52,6 @@ ANN static void plug_get(PlugInfo* p, const m_str c) { const driver drv = DLFUNC(dl, driver, GWDRIVER_NAME); if(drv) { const modstr str = DLFUNC(dl, modstr, GWMODSTR_NAME); -printf("%s %s\n", __func__, str()); -// map_set(&p->drv, (vtype)str(), (vtype)drv); map_set(&p->drv, (vtype)str(), (vtype)drv); } } else @@ -95,21 +93,25 @@ void plug_end(const Gwion gwion) { map_release(&gwion->plug->drv); } +ANN Vector split_args(const m_str str) { + const m_str arg = strchr(str, '='); + m_str c, d = strdup(arg+1); + c = d; + const Vector args = new_vector(); + while(d) + vector_add(args, (vtype)strdup(strsep(&d, ","))); + free(d); + free(c); + return args; +} + ANN static Vector get_arg(const m_str name, const Vector v) { const size_t len = strlen(name); for(m_uint i = vector_size(v) + 1; --i;) { const m_str str = (m_str)vector_at(v, i - 1); if(!strncmp(name, str, len)) { - const m_str arg = strchr(str, '='); - m_str c, d = strdup(arg+1); - c = d; - const Vector args = new_vector(); - while(d) - vector_add(args, (vtype)strdup(strsep(&d, ","))); - free(d); - free(c); vector_rem(v, i-1); - return args; + return split_args(str); } } return NULL; diff --git a/src/vm/vm.c b/src/vm/vm.c index 49f9dcd2..91f22138 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -71,9 +71,11 @@ void vm_remove(const VM* vm, const m_uint index) { ANN void free_vm(VM* vm) { vector_release(&vm->shreduler->shreds); vector_release(&vm->ugen); - xfree(vm->bbq->in); - xfree(vm->bbq->out); - xfree(vm->bbq); + if(vm->bbq) { + xfree(vm->bbq->in); + xfree(vm->bbq->out); + xfree(vm->bbq); + } xfree(vm->shreduler); free(vm); }