MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / deliverCallbacks

Function deliverCallbacks

modules/pins/i2s/audioout.c:1799–1841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1797#if PICO_BUILD || defined(__ets__) || ESP32 || defined(_WIN32)
1798
1799void deliverCallbacks(void *the, void *refcon, uint8_t *message, uint16_t messageLength)
1800{
1801 modAudioOut out = refcon;
1802
1803 xsBeginHost(out->the);
1804 xsmcVars(1);
1805
1806 upUseCount(out);
1807
1808 while (out->pendingCallbackCount) {
1809 xsIntegerValue id;
1810 xsIntegerValue stream;
1811
1812 doLock(out);
1813
1814 id = out->pendingCallbacks[0].id;
1815 stream = out->pendingCallbacks[0].stream;
1816
1817 out->pendingCallbackCount -= 1;
1818 if (out->pendingCallbackCount)
1819 c_memmove(out->pendingCallbacks, out->pendingCallbacks + 1, out->pendingCallbackCount * sizeof(modAudioOutPendingCallbackRecord));
1820
1821 doUnlock(out);
1822
1823 xsmcSetInteger(xsVar(0), id);
1824 xsTry {
1825 xsmcGet(xsResult, out->obj, xsID_callbacks);
1826 if (xsUndefinedType != xsmcTypeOf(xsResult)) {
1827 xsmcGetIndex(xsResult, xsResult, stream);
1828 if (xsmcIsCallable(xsResult))
1829 xsCallFunction1(xsResult, out->obj, xsVar(0));
1830 }
1831 else
1832 xsCall1(out->obj, xsID_callback, xsVar(0));
1833 }
1834 xsCatch {
1835 }
1836 }
1837
1838 xsEndHost(out->the);
1839
1840 downUseCount(out);
1841}
1842
1843// note: queueCallback relies on caller to lock mutex
1844void queueCallback(modAudioOut out, xsIntegerValue id, xsIntegerValue stream)

Callers 2

xs_audioout_enqueueFunction · 0.70
modAudioWindowProcFunction · 0.70

Calls 3

doLockFunction · 0.85
doUnlockFunction · 0.85
downUseCountFunction · 0.85

Tested by

no test coverage detected