diff options
author | Matthew Gregan <[email protected]> | 2012-12-05 09:33:43 +1300 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2012-12-05 09:34:14 +1300 |
commit | 682231bb0fea0f1f904de823f0aa3aa4851378b4 (patch) | |
tree | 4e60745a3a45282f01844e531786e6522984277a | |
parent | 9cd4846d6b7bf274038482e86d566abcef431e85 (diff) | |
download | cubeb-682231bb0fea0f1f904de823f0aa3aa4851378b4.tar.gz cubeb-682231bb0fea0f1f904de823f0aa3aa4851378b4.zip |
winmm: process work items in batches to avoid stream starvation.
-rw-r--r-- | src/cubeb_winmm.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cubeb_winmm.c b/src/cubeb_winmm.c index 9615ef7..0afb3a5 100644 --- a/src/cubeb_winmm.c +++ b/src/cubeb_winmm.c @@ -169,9 +169,15 @@ cubeb_buffer_thread(void * user_ptr) rv = WaitForSingleObject(ctx->event, INFINITE); assert(rv == WAIT_OBJECT_0); - while ((item = InterlockedPopEntrySList(ctx->work)) != NULL) { - cubeb_refill_stream(((struct cubeb_stream_item *) item)->stream); - _aligned_free(item); + /* 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; + cubeb_refill_stream(((struct cubeb_stream_item *) tmp)->stream); + item = item->Next; + _aligned_free(tmp); } if (ctx->shutdown) { |