diff options
author | Paul Adenot <[email protected]> | 2023-04-25 15:51:27 +0200 |
---|---|---|
committer | Paul Adenot <[email protected]> | 2023-04-26 14:28:46 +0200 |
commit | d478bff5fb4f44616dd620d27a2e80b5ca8464ed (patch) | |
tree | 7ca6fea6bc938ca2995ad02e0790870fd4ac80c7 | |
parent | 47720cbc03131f4784558dcf91e8b264e20d5538 (diff) | |
download | cubeb-d478bff5fb4f44616dd620d27a2e80b5ca8464ed.tar.gz cubeb-d478bff5fb4f44616dd620d27a2e80b5ca8464ed.zip |
Don't wait in winmm_stream_destroy when the return value of the data callback is an error.
-rw-r--r-- | src/cubeb_winmm.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/cubeb_winmm.c b/src/cubeb_winmm.c index 2ca86b2..9aa176e 100644 --- a/src/cubeb_winmm.c +++ b/src/cubeb_winmm.c @@ -105,6 +105,7 @@ struct cubeb_stream { int free_buffers; int shutdown; int draining; + int error; HANDLE event; HWAVEOUT waveout; CRITICAL_SECTION lock; @@ -171,6 +172,10 @@ winmm_refill_stream(cubeb_stream * stm) ALOG("winmm_refill_stream"); EnterCriticalSection(&stm->lock); + if (stm->error) { + LeaveCriticalSection(&stm->lock); + return; + } stm->free_buffers += 1; XASSERT(stm->free_buffers > 0 && stm->free_buffers <= NBUFS); @@ -200,8 +205,8 @@ winmm_refill_stream(cubeb_stream * stm) got = stm->data_callback(stm, stm->user_ptr, NULL, hdr->lpData, wanted); EnterCriticalSection(&stm->lock); if (got < 0) { + stm->error = 1; LeaveCriticalSection(&stm->lock); - stm->shutdown = 1; SetEvent(stm->event); stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR); return; @@ -614,7 +619,7 @@ winmm_stream_destroy(cubeb_stream * stm) LeaveCriticalSection(&stm->lock); /* Wait for all blocks to complete. */ - while (device_valid && enqueued > 0) { + while (device_valid && enqueued > 0 && !stm->error) { DWORD rv = WaitForSingleObject(stm->event, INFINITE); XASSERT(rv == WAIT_OBJECT_0); |