Mercurial > hg > dmlib
diff dmtimeline.c @ 368:08ea68abb1f8
Work towards re-entrancy.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Wed, 17 Oct 2012 00:01:46 +0300 |
parents | 5eafdc396fa4 |
children | 1712cc35e9a1 |
line wrap: on
line diff
--- a/dmtimeline.c Tue Oct 16 23:31:19 2012 +0300 +++ b/dmtimeline.c Wed Oct 17 00:01:46 2012 +0300 @@ -1,93 +1,4 @@ -#include "dmtimeline.h" - - -DMEffect *dmEffects = NULL; -int ndmEffects = 0, ndmEffectsAlloc = 0; -void **dmEffectData = NULL; - - -int dmRegisterEffect(const DMEffect *ef) -{ - if (ef == NULL) - return DMERR_NULLPTR; - - // Allocate more space for effects - if (ndmEffects + 1 >= ndmEffectsAlloc) - { - ndmEffectsAlloc += 16; - dmEffects = dmRealloc(dmEffects, sizeof(DMEffect) * ndmEffectsAlloc); - if (dmEffects == NULL) - { - dmError("Could not expand effects structure.\n"); - return DMERR_INIT_FAIL; - } - - dmEffectData = dmRealloc(dmEffectData, sizeof(void *) * ndmEffectsAlloc); - if (dmEffectData == NULL) - { - dmError("Could not expand effects data structure.\n"); - return DMERR_INIT_FAIL; - } - } - - // Copy effects structure - memcpy(dmEffects + ndmEffects, ef, sizeof(DMEffect)); - dmEffectData[ndmEffects] = NULL; - - ndmEffects++; - - return DMERR_OK; -} - - -int dmInitializeEffects() -{ - int i, res; - for (i = 0; i < ndmEffects; i++) - { - if (dmEffects[i].init != NULL && - (res = dmEffects[i].init(&dmEffectData[i])) != DMERR_OK) - return res; - } - - return DMERR_OK; -} - - -void dmShutdownEffects() -{ - int i; - for (i = 0; i < ndmEffects; i++) - { - if (dmEffects[i].shutdown != NULL) - dmEffects[i].shutdown(dmEffectData[i]); - } -} - - -DMEffect *dmFindEffect(const char *name, const int nparams) -{ - int i; - for (i = 0; i < ndmEffects; i++) - { - if (strcmp(dmEffects[i].name, name) == 0 && - dmEffects[i].nparams == nparams) - return &dmEffects[i]; - } - return NULL; -} - - -DMEffect *dmFindEffectByName(const char *name) -{ - int i; - for (i = 0; i < ndmEffects; i++) - { - if (strcmp(dmEffects[i].name, name) == 0) - return &dmEffects[i]; - } - return NULL; -} +#include "dmengine.h" static BOOL dmLoadFloatValue(DMResource *res, DMFloat *val) @@ -240,7 +151,7 @@ event->start = hdr.start; event->duration = hdr.duration; event->nparams = hdr.nparams; - event->effect = dmFindEffect(hdr.effectName, hdr.nparams); + event->effect = engineFindEffect(hdr.effectName, hdr.nparams); if (event->effect == NULL) { dmError("No matching registered effect found for '%s'.\n", hdr.effectName);