From 5233af2142e5fd045f922a82fef0c76c62684a7b Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Tue, 14 Oct 2003 22:16:32 +0000 Subject: Add a callback to the buffer_pool_alloc function. The goal is to detect in the net_buf_ctrl if there is no more free buffer in a fifo, which indicates there will be a deadlock if the engine is not unpaused. Currently this detection is done from the "put" callback, it's not a safe solution, nothing prevents a demuxer to allocate 2 buffers before calling put(). The impact is low, only one test per buffer_pool_alloc call if no callback is registered. It's done exactly the same way as the put and get callbacks. CVS patchset: 5520 CVS date: 2003/10/14 22:16:32 --- src/xine-engine/buffer.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/xine-engine/buffer.h') diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index da2afa28f..abe3457b7 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.120 2003/08/05 15:20:00 mroi Exp $ + * $Id: buffer.h,v 1.121 2003/10/14 22:16:32 tmattern Exp $ * * * contents: @@ -467,8 +467,11 @@ struct fifo_buffer_s /* the same as put but insert at the head of the fifo */ void (*insert) (fifo_buffer_t *fifo, buf_element_t *buf); + /* callbacks */ + void (*register_alloc_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, void *), void *cb_data); void (*register_put_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *), void *cb_data); void (*register_get_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *), void *cb_data); + void (*unregister_alloc_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, void *)); void (*unregister_put_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *)); void (*unregister_get_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *)); @@ -479,11 +482,13 @@ struct fifo_buffer_s pthread_mutex_t buffer_pool_mutex; pthread_cond_t buffer_pool_cond_not_empty; int buffer_pool_num_free; - int buffer_pool_capacity; - int buffer_pool_buf_size; + int buffer_pool_capacity; + int buffer_pool_buf_size; void *buffer_pool_base; /*used to free mem chunk */ + void (*alloc_cb[BUF_MAX_CALLBACKS])(fifo_buffer_t *fifo, void *data_cb); void (*put_cb[BUF_MAX_CALLBACKS])(fifo_buffer_t *fifo, buf_element_t *buf, void *data_cb); void (*get_cb[BUF_MAX_CALLBACKS])(fifo_buffer_t *fifo, buf_element_t *buf, void *data_cb); + void *alloc_cb_data[BUF_MAX_CALLBACKS]; void *put_cb_data[BUF_MAX_CALLBACKS]; void *get_cb_data[BUF_MAX_CALLBACKS]; } ; -- cgit v1.2.3