From e19c38b7c3647031b8cf47d1a0ecb509a3795d7d Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Sun, 23 Feb 2003 19:27:57 +0000 Subject: New method to get the number of free elements in the pool. It will be used in net_buf_ctrl to detect if a fifo is full. You need to recompile the whole lib after this patch. CVS patchset: 4265 CVS date: 2003/02/23 19:27:57 --- src/xine-engine/buffer.c | 18 ++++++++++++++++-- src/xine-engine/buffer.h | 10 ++++++---- 2 files changed, 22 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/xine-engine/buffer.c b/src/xine-engine/buffer.c index 7524196bc..38aaa0ec6 100644 --- a/src/xine-engine/buffer.c +++ b/src/xine-engine/buffer.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.c,v 1.24 2003/02/22 14:12:45 mroi Exp $ + * $Id: buffer.c,v 1.25 2003/02/23 19:27:57 tmattern Exp $ * * * contents: @@ -132,7 +132,7 @@ static buf_element_t *buffer_pool_try_alloc (fifo_buffer_t *this) { buf = this->buffer_pool_top; this->buffer_pool_top = this->buffer_pool_top->next; this->buffer_pool_num_free--; - + } else { buf = NULL; @@ -290,6 +290,19 @@ static uint32_t fifo_buffer_data_size (fifo_buffer_t *this) { return data_size; } +/* + * Return the number of free elements in the pool + */ +static int fifo_buffer_num_free (fifo_buffer_t *this) { + int buffer_pool_num_free; + + pthread_mutex_lock(&this->mutex); + buffer_pool_num_free = this->buffer_pool_num_free; + pthread_mutex_unlock(&this->mutex); + + return buffer_pool_num_free; +} + /* * Destroy the buffer */ @@ -349,6 +362,7 @@ fifo_buffer_t *fifo_buffer_new (int num_buffers, uint32_t buf_size) { this->get = fifo_buffer_get; this->clear = fifo_buffer_clear; this->size = fifo_buffer_size; + this->num_free = fifo_buffer_num_free; this->data_size = fifo_buffer_data_size; this->dispose = fifo_buffer_dispose; diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 008e130df..4aeb6d0a1 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.h,v 1.101 2003/02/19 21:37:16 jstembridge Exp $ + * $Id: buffer.h,v 1.102 2003/02/23 19:27:57 tmattern Exp $ * * * contents: @@ -228,7 +228,7 @@ struct buf_element_s { int64_t disc_off; /* discontinuity offset */ extra_info_t *extra_info; /* extra info will be passed to frames */ - + uint32_t decoder_flags; /* stuff like keyframe, is_header ... see below */ uint32_t decoder_info[4]; /* additional decoder flags and other dec-spec. stuff */ @@ -253,7 +253,7 @@ struct buf_element_s { #define BUF_FLAG_SPECIAL 0x0200 #define BUF_FLAG_NO_VIDEO 0x0400 /* do not decode the buffer contents, detect framing only */ -#define BUF_FLAG_FRAMING 0x0800 +#define BUF_FLAG_FRAMING 0x0800 /* Special buffer types: * Sometimes there is a need to relay special information from a demuxer @@ -322,7 +322,7 @@ struct buf_element_s { * decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG * decoder_info[2] = data size * decoder_info_ptr[2] = pointer to data - * This buffer is used to pass config information from .mp4 files + * This buffer is used to pass config information from .mp4 files * (atom esds) to decoders. both mpeg4 and aac streams use that. */ #define BUF_SPECIAL_DECODER_CONFIG 4 @@ -413,6 +413,8 @@ struct fifo_buffer_s int (*size) (fifo_buffer_t *fifo); + int (*num_free) (fifo_buffer_t *fifo); + uint32_t (*data_size) (fifo_buffer_t *fifo); void (*dispose) (fifo_buffer_t *fifo); -- cgit v1.2.3