From 80640de72078beb50796ff28d068dfd085299b86 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sat, 4 Oct 2003 14:36:05 +0000 Subject: Fix a deadlock. Patch from Ramon van der Aar CVS patchset: 5434 CVS date: 2003/10/04 14:36:05 --- src/input/net_buf_ctrl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index 0138f1234..eb4ee3894 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -284,8 +284,12 @@ static void nbc_put_cb (fifo_buffer_t *fifo, * - high_water_mark is reached by all fifos * do not restart if has_video and has_audio are false to avoid * a yoyo effect at the beginning of the stream when these values - * are not yet known. */ - if ((fifo->buffer_pool_num_free <= 1) || + * are not yet known. + * + * be sure that the next buffer_pool_alloc() call will not deadlock, + * we need at least 2 buffers (see buffer.c) + */ + if ((fifo->buffer_pool_num_free <= 2) || (((!has_video) || (this->video_fifo_length > this->high_water_mark)) && ((!has_audio) || (this->audio_fifo_length > this->high_water_mark)) && (has_video || has_audio))) { @@ -362,7 +366,7 @@ static void nbc_get_cb (fifo_buffer_t *fifo, /* Don't pause if the other fifo is full because the next put() will restart the engine */ - if (other_fifo_free > 1) { + if (other_fifo_free > 2) { this->buffering = 1; this->progress = 0; report_progress (this->stream, 0); -- cgit v1.2.3