From 124787ffe4966716b4a7711724d81102099b868b Mon Sep 17 00:00:00 2001 From: Michael Roitzsch Date: Thu, 10 Feb 2005 11:33:31 +0000 Subject: **BUGFIX** prevent a possible deadlock situation by un-nesting the resource locking CVS patchset: 7397 CVS date: 2005/02/10 11:33:31 --- src/xine-engine/demux.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c index 27c63d2a7..ff0b78a1d 100644 --- a/src/xine-engine/demux.c +++ b/src/xine-engine/demux.c @@ -20,7 +20,7 @@ * Demuxer helper functions * hide some xine engine details from demuxers and reduce code duplication * - * $Id: demux.c,v 1.54 2004/12/19 20:24:31 miguelfreitas Exp $ + * $Id: demux.c,v 1.55 2005/02/10 11:33:31 mroi Exp $ */ @@ -139,7 +139,14 @@ void _x_demux_control_headers_done (xine_stream_t *stream) { int header_count_audio; int header_count_video; - buf_element_t *buf; + buf_element_t *buf_video, *buf_audio; + + /* we use demux_action_pending to wake up sleeping spu decoders */ + stream->demux_action_pending = 1; + + /* allocate the buffers before grabbing the lock to prevent cyclic wait situations */ + buf_video = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); + buf_audio = stream->audio_fifo->buffer_pool_alloc (stream->audio_fifo); pthread_mutex_lock (&stream->counter_lock); @@ -155,16 +162,11 @@ void _x_demux_control_headers_done (xine_stream_t *stream) { header_count_audio = 0; } - /* we use demux_action_pending to wake up sleeping spu decoders */ - stream->demux_action_pending = 1; - - buf = stream->video_fifo->buffer_pool_alloc (stream->video_fifo); - buf->type = BUF_CONTROL_HEADERS_DONE; - stream->video_fifo->put (stream->video_fifo, buf); + buf_video->type = BUF_CONTROL_HEADERS_DONE; + stream->video_fifo->put (stream->video_fifo, buf_video); - buf = stream->audio_fifo->buffer_pool_alloc (stream->audio_fifo); - buf->type = BUF_CONTROL_HEADERS_DONE; - stream->audio_fifo->put (stream->audio_fifo, buf); + buf_audio->type = BUF_CONTROL_HEADERS_DONE; + stream->audio_fifo->put (stream->audio_fifo, buf_audio); while ((stream->header_count_audio < header_count_audio) || (stream->header_count_video < header_count_video)) { -- cgit v1.2.3