From 616297652365dc3b0a3bb4f7f86664e3c4e4b779 Mon Sep 17 00:00:00 2001 From: Miguel Freitas Date: Sun, 5 Feb 2006 19:09:18 +0000 Subject: try to fix "deadlock" in ao_open() when waiting on empty out_fifo to get empty as reported by Reinhard Nissl CVS patchset: 7877 CVS date: 2006/02/05 19:09:18 --- src/xine-engine/audio_out.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index a3e8e70be..b6c7b7a4e 100644 --- a/src/xine-engine/audio_out.c +++ b/src/xine-engine/audio_out.c @@ -17,7 +17,7 @@ * along with self program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: audio_out.c,v 1.195 2006/01/27 07:46:15 tmattern Exp $ + * $Id: audio_out.c,v 1.196 2006/02/05 19:09:18 miguelfreitas Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe @@ -360,6 +360,7 @@ static audio_buffer_t *fifo_remove_int (audio_fifo_t *fifo, int blocking) { fifo->last = NULL; fifo->num_buffers = 0; + pthread_cond_signal (&fifo->empty); } else fifo->num_buffers--; @@ -410,8 +411,12 @@ static int fifo_num_buffers (audio_fifo_t *fifo) { static void fifo_wait_empty (audio_fifo_t *fifo) { pthread_mutex_lock (&fifo->mutex); - pthread_cond_signal (&fifo->not_empty); - pthread_cond_wait (&fifo->empty, &fifo->mutex); + while (fifo->first) { + /* i think it's strange to send not_empty signal here (beside the enqueue + * function), but it should do no harm. [MF] */ + pthread_cond_signal (&fifo->not_empty); + pthread_cond_wait (&fifo->empty, &fifo->mutex); + } pthread_mutex_unlock (&fifo->mutex); } -- cgit v1.2.3