| 523 | static int ndspRefCount = 0; |
| 524 | |
| 525 | Result 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 | |
| 574 | void ndspExit(void) |
| 575 | { |
nothing calls this directly
no test coverage detected