From c241f4976885ebf91981155f7b2be567a24aca80 Mon Sep 17 00:00:00 2001 From: fennecdjay Date: Fri, 31 Mar 2023 12:30:10 +0200 Subject: [PATCH] :art: Driver system updates --- include/plug.h | 2 +- include/vm.h | 2 +- plug | 2 +- src/gwion.c | 2 +- src/main.c | 2 +- src/plug.c | 11 +++++------ 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/include/plug.h b/include/plug.h index 7bac9fb4..7551eec0 100644 --- a/include/plug.h +++ b/include/plug.h @@ -25,7 +25,7 @@ ANN static inline Plug new_plug(MemPool p) { } ANN m_bool plug_ini(const struct Gwion_ *, const Vector); -ANN m_bool driver_ini(const struct Gwion_ *); +ANN gwdriver_t driver_ini(const struct Gwion_ *, struct SoundInfo_ *); ANN m_bool plug_run(const struct Gwion_ *, const Map); ANN void free_plug(const Gwion); ANN void * get_module(const struct Gwion_ *, const m_str); diff --git a/include/vm.h b/include/vm.h index 54cac881..c1a7597a 100644 --- a/include/vm.h +++ b/include/vm.h @@ -137,7 +137,7 @@ ANN uint32_t gw_rand(uint32_t s[2]); ANN void gw_seed(uint32_t s[2], const uint64_t); ANN bool handle(VM_Shred shred, const m_str effect); #define xfun_handle(shred, effect) {\ -/* shred->mem -= ((Instr)vector_at(&shred->code->instr, shred->pc-1))->m_val2; */\ + shred->mem -= ((Instr)vector_at(&shred->code->instr, shred->pc-1))->m_val2; \ handle(shred, effect); \ } diff --git a/plug b/plug index 05ab62e2..3410ba04 160000 --- a/plug +++ b/plug @@ -1 +1 @@ -Subproject commit 05ab62e2ce4b00c4e1f380fd4e27adf4946b0bc0 +Subproject commit 3410ba0416ba3d2c18305f5a0518541c8aa90626 diff --git a/src/gwion.c b/src/gwion.c index a2754a3b..27c14c03 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -18,7 +18,7 @@ ANN m_bool gwion_audio(const Gwion gwion) { Driver *const di = gwion->vm->bbq; - if (di->si->arg) CHECK_BB(driver_ini(gwion)); + if (di->si->arg) CHECK_OB((di->func = driver_ini(gwion, di->si))); di->func(di->driver); CHECK_BB(di->driver->ini(gwion->vm, di)); driver_alloc(di); diff --git a/src/main.c b/src/main.c index b2d1be35..dd4139f7 100644 --- a/src/main.c +++ b/src/main.c @@ -63,7 +63,7 @@ int main(int argc, char **argv) { #ifdef GWION_EMBED gwion_embed(&gwion); #endif - arg_compile(&gwion, &arg); + if(ini > 0) arg_compile(&gwion, &arg); arg_release(&arg); #ifdef GWION_CONFIG_ARGS free(config_argv); diff --git a/src/plug.c b/src/plug.c index cd516432..d6cb87aa 100644 --- a/src/plug.c +++ b/src/plug.c @@ -235,9 +235,9 @@ ANN m_bool plugin_ini(struct Gwion_ *gwion, const m_str iname, const loc_t loc) return GW_OK; } -ANN m_bool driver_ini(const struct Gwion_ *gwion) { +ANN gwdriver_t driver_ini(const struct Gwion_ *gwion, struct SoundInfo_ *si) { const Map map = &gwion->data->plugs->map; - m_str dname = gwion->vm->bbq->si->arg; + m_str dname = si->arg; m_str opt = strchr(dname, '='); const char c = opt ? *opt : '\0'; if (opt) *opt = '\0'; @@ -246,14 +246,13 @@ ANN m_bool driver_ini(const struct Gwion_ *gwion) { if (!strcmp(name, dname)) { const Plug plug = (Plug)VVAL(map, i); const gwdriver_t drv = plug->driver; - if (!drv) break; - gwion->vm->bbq->func = drv; if (opt) *opt = c; - return GW_OK; + return drv; } } + if (opt) *opt = c; gw_err("can't find driver '%s'\n", dname); - return GW_ERROR; + return NULL; } ANN void *get_module(const struct Gwion_ *gwion, const m_str name) { -- 2.43.0