From: fennecdjay Date: Wed, 8 May 2024 19:08:40 +0000 (+0200) Subject: :art: better vm_force_run X-Git-Tag: nightly~15 X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=d721d0fb30b6a78bfe8dd9abc2e1480b435f3c20;p=gwion.git :art: better vm_force_run --- diff --git a/src/emit/comptime.c b/src/emit/comptime.c index 0206a952..ce0054b5 100644 --- a/src/emit/comptime.c +++ b/src/emit/comptime.c @@ -24,7 +24,7 @@ ANN2(1) void comptime_end(const Emitter emit, const size_t size, void *data) { const VM_Shred shred = new_vm_shred(emit->gwion->mp, code); vm_add_shred(vm, shred); const bool loop = vm->shreduler->loop; - vm_run(vm); - vm->bbq->is_running = true; + vm->shreduler->loop = false; + vm_force_run(vm); vm->shreduler->loop = loop; } diff --git a/src/vm/vm.c b/src/vm/vm.c index 624241ba..5613b511 100644 --- a/src/vm/vm.c +++ b/src/vm/vm.c @@ -1657,8 +1657,15 @@ ANN void vm_run_audio(const VM *vm) { void vm_force_run(const VM *vm) { const bool is_running = vm->shreduler->bbq->is_running; + struct ShredTick_ *curr = vm->shreduler->curr; + VM_Shred shred = (VM_Shred) vector_back(&vm->shreduler->active_shreds); + vm->shreduler->curr = shred->tick; + const m_uint pos = vm->shreduler->bbq->pos; + vm->shreduler->bbq->pos = 0; vm_run(vm); + vm->shreduler->curr = curr; vm->shreduler->bbq->is_running = is_running; + vm->shreduler->bbq->pos = pos; } VM *new_vm(MemPool p, const bool audio) {