From: fennecdjay Date: Tue, 12 Mar 2019 20:40:48 +0000 (+0100) Subject: :art: More X-Git-Tag: nightly~2745 X-Git-Url: http://10.11.0.4:5575/?a=commitdiff_plain;h=a5ca6553d5d372528015b5f665adcf6928a7d0c1;p=gwion.git :art: More --- diff --git a/include/driver.h b/include/driver.h index d3c88f93..2d5b9cf1 100644 --- a/include/driver.h +++ b/include/driver.h @@ -4,12 +4,13 @@ typedef m_bool (*f_drvini)(VM*, struct BBQ_*); typedef void (*f_drvrun)(VM*, struct BBQ_*); typedef void (*f_drvdel)(VM*, struct BBQ_*); - +#define DRVRUN(a) void a(VM *vm, struct BBQ_* di) +#define DRVDEL(a) void a(VM *vm, struct BBQ_* di) typedef struct DriverData_ { + void* data; f_drvini ini; f_drvrun run; f_drvdel del; - void* data; } DriverData; ANN void dummy_driver(DriverData*); diff --git a/src/gwion.c b/src/gwion.c index 449284a5..cf56ce38 100644 --- a/src/gwion.c +++ b/src/gwion.c @@ -30,7 +30,7 @@ ANN static struct BBQ_ * new_driverinfo(void) { struct BBQ_ * di = (struct BBQ_*)xcalloc(1, sizeof(struct BBQ_)); di->func = dummy_driver; di->run = vm_run; - di->driver = (DriverData*)xcalloc(1, sizeof(DriverData)); + di->driver = (DriverData*)mp_alloc(DriverData); return di; } @@ -103,20 +103,20 @@ ANN void gwion_run(const Gwion gwion) { VMBENCH_END } -ANN /* static */ void free_driverinfo(struct BBQ_* di, VM* vm) { - mp_free(SoundInfo, di->si); - if(di->driver->del) - di->driver->del(vm, di); - xfree(di->driver); - xfree(di); +ANN /* static */ void free_driverinfo(struct BBQ_* bbq, VM* vm) { + mp_free(SoundInfo, bbq->si); + if(bbq->driver->del) + bbq->driver->del(vm, bbq); + mp_free(DriverData, bbq->driver); + xfree(bbq); } ANN void gwion_end(const Gwion gwion) { - plug_end(gwion); arg_release(gwion->arg); xfree(gwion->arg); free_env(gwion->env); free_emitter(gwion->emit); free_vm(gwion->vm); + plug_end(gwion); xfree(gwion->plug); free_symbols(); } diff --git a/src/vm/vm.c b/src/vm/vm.c index 523b67fc..068586de 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -67,16 +67,22 @@ void vm_remove(const VM* vm, const m_uint index) { Except(sh, "MsgRemove"); } } - +#include "sound.h" ANN void free_vm(VM* vm) { vector_release(&vm->shreduler->shreds); vector_release(&vm->ugen); +struct BBQ_* bbq = vm->bbq; if(vm->bbq) { + mp_free(SoundInfo, bbq->si); + if(bbq->driver->del) + bbq->driver->del(vm, bbq); + mp_free(DriverData, bbq->driver); if(vm->bbq->in) xfree(vm->bbq->in); if(vm->bbq->out) xfree(vm->bbq->out); - free_driverinfo(vm->bbq, vm); + xfree(bbq); +// free_driverinfo(vm->bbq, vm); } xfree(vm->shreduler); free(vm);