MCPcopy Create free account
hub / github.com/csound/csound / csoundInitModule

Function csoundInitModule

Top/csmodule.c:243–281  ·  view source on GitHub ↗

* Initialise a single module. * Return value is CSOUND_SUCCESS if there was no error. */

Source from the content-addressed store, hash-verified

241 * Return value is CSOUND_SUCCESS if there was no error.
242 */
243static CS_NOINLINE int csoundInitModule(CSOUND *csound, csoundModule_t *m)
244{
245 int i;
246
247 if (m->PreInitFunc != NULL) {
248 if (m->fn.p.InitFunc != NULL) {
249 i = m->fn.p.InitFunc(csound);
250 if (UNLIKELY(i != 0)) {
251 print_module_error(csound, Str("Error starting module '%s'"),
252 &(m->name[0]), m, i);
253 return CSOUND_ERROR;
254 }
255 }
256 }
257 else {
258 /* deal with fgens if there are any */
259 if (m->fn.o.fgen_init != NULL) {
260 NGFENS *names = m->fn.o.fgen_init(csound);
261 for (i = 0; names[i].name != NULL; i++)
262 allocgen(csound, names[i].name, names[i].fn);
263 }
264 if (m->fn.o.opcode_init != NULL) {
265 OENTRY *opcodlst_n;
266 int64_t length;
267 /* load opcodes */
268 if (UNLIKELY((length = m->fn.o.opcode_init(csound, &opcodlst_n)) < 0L))
269 return CSOUND_ERROR;
270 else {
271 length /= (long) sizeof(OENTRY);
272 if (length) {
273 if (UNLIKELY(csoundAppendOpcodes(csound, opcodlst_n,
274 (int) length) != 0))
275 return CSOUND_ERROR;
276 }
277 }
278 }
279 }
280 return CSOUND_SUCCESS;
281}
282
283
284#ifdef __wasi__

Callers 2

csoundInitModulesFunction · 0.85
csoundLoadAndInitModuleFunction · 0.85

Calls 3

print_module_errorFunction · 0.85
allocgenFunction · 0.85
csoundAppendOpcodesFunction · 0.85

Tested by

no test coverage detected