diff options
author | Matthew Gregan <[email protected]> | 2011-12-01 17:18:30 +1300 |
---|---|---|
committer | Matthew Gregan <[email protected]> | 2011-12-01 17:18:30 +1300 |
commit | fc6e838a0078a10ecc306f5c671c07ec2bfe7607 (patch) | |
tree | d4d274be4ffd767adf4d1da11d5d8c08f0129043 /src | |
parent | ed04e5a0d6ee369d55181026a495214815880796 (diff) | |
download | cubeb-fc6e838a0078a10ecc306f5c671c07ec2bfe7607.tar.gz cubeb-fc6e838a0078a10ecc306f5c671c07ec2bfe7607.zip |
alsa: take lock in refill. resume stream earlier.
Diffstat (limited to 'src')
-rw-r--r-- | src/cubeb_alsa.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/cubeb_alsa.c b/src/cubeb_alsa.c index 7724a39..4d688fc 100644 --- a/src/cubeb_alsa.c +++ b/src/cubeb_alsa.c @@ -456,13 +456,17 @@ cubeb_refill_stream(void * stream, struct pollfd * fds, nfds_t nfds) long got; void * p; + pthread_mutex_lock(&stm->mutex); + r = snd_pcm_poll_descriptors_revents(stm->pcm, fds, nfds, &revents); if (r < 0 || revents == POLLERR) { stm->waitable = NULL; + pthread_mutex_unlock(&stm->mutex); return XPOLL_WAITABLE_REMOVE; } if (revents != POLLOUT) { + pthread_mutex_unlock(&stm->mutex); return XPOLL_WAITABLE_CONTINUE; } @@ -473,6 +477,7 @@ cubeb_refill_stream(void * stream, struct pollfd * fds, nfds_t nfds) } if (avail < 0) { stm->waitable = NULL; + pthread_mutex_unlock(&stm->mutex); return XPOLL_WAITABLE_REMOVE; } @@ -502,7 +507,10 @@ cubeb_refill_stream(void * stream, struct pollfd * fds, nfds_t nfds) free(p); - return stm->waitable ? XPOLL_WAITABLE_CONTINUE : XPOLL_WAITABLE_REMOVE; + r = stm->waitable ? XPOLL_WAITABLE_CONTINUE : XPOLL_WAITABLE_REMOVE; + pthread_mutex_unlock(&stm->mutex); + + return r; } static void * @@ -694,6 +702,8 @@ cubeb_stream_start(cubeb_stream * stm) return CUBEB_OK; } + snd_pcm_pause(stm->pcm, 0); + nfds = snd_pcm_poll_descriptors_count(stm->pcm); assert(nfds > 0); @@ -702,7 +712,6 @@ cubeb_stream_start(cubeb_stream * stm) r = snd_pcm_poll_descriptors(stm->pcm, fds, nfds); assert(r == nfds); - snd_pcm_pause(stm->pcm, 0); stm->waitable = xpoll_waitable_init(stm->context->xpoll, fds, nfds, cubeb_refill_stream, stm); free(fds); |