From 893ce18a8d50ea86c90a80faa0f54ef5ca626d3d Mon Sep 17 00:00:00 2001 From: Pale Moon Date: Wed, 29 Nov 2017 23:12:52 +0100 Subject: [PATCH] Rewrite assert in cubeb_alsa.c: alsa_refill_stream to pass back a cubeb error instead. This should fix the assertion failure in #1515. --- media/libcubeb/src/cubeb_alsa.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/media/libcubeb/src/cubeb_alsa.c b/media/libcubeb/src/cubeb_alsa.c index 5901a3b5bd..6ac7cb3afd 100644 --- a/media/libcubeb/src/cubeb_alsa.c +++ b/media/libcubeb/src/cubeb_alsa.c @@ -333,7 +333,12 @@ alsa_refill_stream(cubeb_stream * stm) snd_pcm_recover(stm->pcm, wrote, 1); wrote = snd_pcm_writei(stm->pcm, p, got); } - assert(wrote >= 0 && wrote == got); + if (wrote < 0 || wrote != got) { + /* Recovery failed, somehow. */ + pthread_mutex_unlock(&stm->mutex); + stm->state_callback(stm, stm->user_ptr, CUBEB_STATE_ERROR); + return ERROR; + } stm->write_position += wrote; gettimeofday(&stm->last_activity, NULL); }