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

Function doRenderSamples

modules/pins/i2s/audioout.c:1370–1398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1368}
1369
1370void doRenderSamples(modAudioOut out)
1371{
1372 LPBYTE p1, p2;
1373 DWORD b1, b2;
1374 HRESULT hr;
1375 DWORD bytesWritten = out->samplesNeeded * out->bytesPerFrame;
1376
1377 EnterCriticalSection(&out->cs);
1378
1379 audioMix(out, out->samplesNeeded, (OUTPUTSAMPLETYPE*)out->buffer);
1380
1381 hr = IDirectSoundBuffer_Lock(out->dSBuffer, (DWORD)(out->bytesWritten % out->bufferSize), bytesWritten,
1382 (LPVOID *)&p1, &b1, (LPVOID *)&p2, &b2, 0);
1383 if (FAILED(hr))
1384 goto bail;
1385
1386 if (NULL != p1) {
1387 c_memcpy(p1, out->buffer, b1);
1388 if (NULL != p2)
1389 c_memcpy(p2, b1 + out->buffer, b2);
1390 out->bytesWritten += bytesWritten;
1391 out->samplesNeeded = 0;
1392 }
1393
1394 IDirectSoundBuffer_Unlock(out->dSBuffer, p1, b1, p2, b2);
1395
1396bail:
1397 LeaveCriticalSection(&out->cs);
1398}
1399
1400LRESULT CALLBACK modAudioWindowProc(HWND window, UINT message, WPARAM wParam, LPARAM lParam)
1401{

Callers 2

xs_audioout_startFunction · 0.85
modAudioWindowProcFunction · 0.85

Calls 1

audioMixFunction · 0.85

Tested by

no test coverage detected