MCPcopy Create free account
hub / github.com/devkitPro/libctru / ndspInit

Function ndspInit

libctru/source/ndsp/ndsp.c:525–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

523static int ndspRefCount = 0;
524
525Result ndspInit(void)
526{
527 Result rc = 0;
528 if (AtomicPostIncrement(&ndspRefCount)) return 0;
529
530 if (!componentBin && !ndspFindAndLoadComponent())
531 {
532 rc = MAKERESULT(RL_PERMANENT, RS_NOTFOUND, RM_DSP, RD_NOT_FOUND);
533 goto _fail0;
534 }
535
536 LightLock_Init(&ndspMutex);
537 LightEvent_Init(&sleepEvent, RESET_STICKY);
538
539 rc = dspInit();
540 if (R_FAILED(rc)) goto _fail1;
541
542 rc = DSP_LoadComponent(componentBin, componentSize, componentProgMask, componentDataMask, NULL);
543 if (R_FAILED(rc)) goto _fail2;
544
545 rc = ndspInitialize(false);
546 if (R_FAILED(rc)) goto _fail2;
547
548 ndspiInitChn();
549 ndspInitMaster();
550 ndspUpdateMaster(); // official sw does this upfront, not sure what's the point
551 // TODO: initialize effect params
552
553 ndspThread = threadCreate(ndspThreadMain, 0x0, NDSP_THREAD_STACK_SIZE, 0x18, -2, true);
554 if (!ndspThread) goto _fail3;
555
556 dspHook(&ndspHookCookie, ndspHookCallback);
557 return 0;
558
559_fail3:
560 ndspFinalize(false);
561_fail2:
562 dspExit();
563_fail1:
564 if (componentFree)
565 {
566 free((void*)componentBin);
567 componentBin = NULL;
568 }
569_fail0:
570 AtomicDecrement(&ndspRefCount);
571 return rc;
572}
573
574void ndspExit(void)
575{

Callers

nothing calls this directly

Calls 13

ndspFindAndLoadComponentFunction · 0.85
LightLock_InitFunction · 0.85
LightEvent_InitFunction · 0.85
dspInitFunction · 0.85
DSP_LoadComponentFunction · 0.85
ndspInitializeFunction · 0.85
ndspiInitChnFunction · 0.85
ndspInitMasterFunction · 0.85
ndspUpdateMasterFunction · 0.85
threadCreateFunction · 0.85
dspHookFunction · 0.85
ndspFinalizeFunction · 0.85

Tested by

no test coverage detected