in src/cubeb_winmm.c [251:280]
static unsigned __stdcall winmm_buffer_thread(void * user_ptr)
{
cubeb * ctx = (cubeb *)user_ptr;
XASSERT(ctx);
for (;;) {
DWORD r;
PSLIST_ENTRY item;
r = WaitForSingleObject(ctx->event, INFINITE);
XASSERT(r == WAIT_OBJECT_0);
/* Process work items in batches so that a single stream can't
starve the others by continuously adding new work to the top of
the work item stack. */
item = InterlockedFlushSList(ctx->work);
while (item != NULL) {
PSLIST_ENTRY tmp = item;
winmm_refill_stream(((struct cubeb_stream_item *)tmp)->stream);
item = item->Next;
_aligned_free(tmp);
}
if (ctx->shutdown) {
break;
}
}
return 0;
}