139 строки
5.1 KiB
Diff
139 строки
5.1 KiB
Diff
include/unicap.h | 2 +-
|
|
src/unicap.c | 62 +++++++++++++++++++++++++++---------------------------
|
|
2 files changed, 32 insertions(+), 32 deletions(-)
|
|
|
|
diff --git a/include/unicap.h b/include/unicap.h
|
|
index 43a3040..e516734 100644
|
|
--- a/include/unicap.h
|
|
+++ b/include/unicap.h
|
|
@@ -215,7 +215,7 @@ struct _unicap_data_buffer_t
|
|
|
|
unicap_buffer_flags_t flags;
|
|
|
|
- unicap_data_buffer_private_t *private;
|
|
+ unicap_data_buffer_private_t *priv;
|
|
};
|
|
|
|
typedef struct _unicap_data_buffer_t unicap_data_buffer_t;
|
|
diff --git a/src/unicap.c b/src/unicap.c
|
|
index f56c6f0..adac44d 100644
|
|
--- a/src/unicap.c
|
|
+++ b/src/unicap.c
|
|
@@ -1467,7 +1467,7 @@ unicap_data_buffer_t *unicap_data_buffer_new( unicap_format_t *format )
|
|
buffer->buffer_size = buffer->format.buffer_size;
|
|
buffer->data = malloc( buffer->buffer_size );
|
|
unicap_copy_format( &buffer->format, format );
|
|
- buffer->private = NULL;
|
|
+ buffer->priv = NULL;
|
|
|
|
return buffer;
|
|
}
|
|
@@ -1475,28 +1475,28 @@ unicap_data_buffer_t *unicap_data_buffer_new( unicap_format_t *format )
|
|
void unicap_data_buffer_init( unicap_data_buffer_t *buffer, unicap_format_t *format, unicap_data_buffer_init_data_t *init_data )
|
|
{
|
|
unicap_copy_format( &buffer->format, format );
|
|
- buffer->private = malloc( sizeof( unicap_data_buffer_private_t ) );
|
|
- sem_init( &buffer->private->lock, 0, 1 );
|
|
- buffer->private->ref_count = 0;
|
|
- buffer->private->free_func = init_data->free_func;
|
|
- buffer->private->free_func_data = init_data->free_func_data;
|
|
- buffer->private->ref_func = init_data->ref_func;
|
|
- buffer->private->ref_func_data = init_data->ref_func_data;
|
|
- buffer->private->unref_func = init_data->unref_func;
|
|
- buffer->private->unref_func_data = init_data->unref_func_data;
|
|
+ buffer->priv = malloc( sizeof( unicap_data_buffer_private_t ) );
|
|
+ sem_init( &buffer->priv->lock, 0, 1 );
|
|
+ buffer->priv->ref_count = 0;
|
|
+ buffer->priv->free_func = init_data->free_func;
|
|
+ buffer->priv->free_func_data = init_data->free_func_data;
|
|
+ buffer->priv->ref_func = init_data->ref_func;
|
|
+ buffer->priv->ref_func_data = init_data->ref_func_data;
|
|
+ buffer->priv->unref_func = init_data->unref_func;
|
|
+ buffer->priv->unref_func_data = init_data->unref_func_data;
|
|
}
|
|
|
|
void unicap_data_buffer_free( unicap_data_buffer_t *buffer )
|
|
{
|
|
- sem_wait( &buffer->private->lock );
|
|
- if( buffer->private->ref_count > 0 ){
|
|
- TRACE( "freeing a buffer with refcount = %d!!!\n", buffer->private.refcount );
|
|
+ sem_wait( &buffer->priv->lock );
|
|
+ if( buffer->priv->ref_count > 0 ){
|
|
+ TRACE( "freeing a buffer with refcount = %d!!!\n", buffer->priv.refcount );
|
|
}
|
|
- if( buffer->private->free_func ){
|
|
- buffer->private->free_func( buffer, buffer->private->free_func_data );
|
|
+ if( buffer->priv->free_func ){
|
|
+ buffer->priv->free_func( buffer, buffer->priv->free_func_data );
|
|
}
|
|
|
|
- sem_destroy( &buffer->private->lock );
|
|
+ sem_destroy( &buffer->priv->lock );
|
|
if (buffer->data)
|
|
free( buffer->data );
|
|
free( buffer );
|
|
@@ -1504,9 +1504,9 @@ void unicap_data_buffer_free( unicap_data_buffer_t *buffer )
|
|
|
|
unicap_status_t unicap_data_buffer_ref( unicap_data_buffer_t *buffer )
|
|
{
|
|
- sem_wait( &buffer->private->lock );
|
|
- buffer->private->ref_count++;
|
|
- sem_post( &buffer->private->lock );
|
|
+ sem_wait( &buffer->priv->lock );
|
|
+ buffer->priv->ref_count++;
|
|
+ sem_post( &buffer->priv->lock );
|
|
|
|
return STATUS_SUCCESS;
|
|
}
|
|
@@ -1514,14 +1514,14 @@ unicap_status_t unicap_data_buffer_ref( unicap_data_buffer_t *buffer )
|
|
unicap_status_t unicap_data_buffer_unref( unicap_data_buffer_t *buffer )
|
|
{
|
|
unicap_status_t status = STATUS_SUCCESS;
|
|
- sem_wait( &buffer->private->lock );
|
|
- if( buffer->private->ref_count > 0 ){
|
|
- buffer->private->ref_count--;
|
|
- if (buffer->private->unref_func){
|
|
- buffer->private->unref_func (buffer, buffer->private->unref_func_data);
|
|
+ sem_wait( &buffer->priv->lock );
|
|
+ if( buffer->priv->ref_count > 0 ){
|
|
+ buffer->priv->ref_count--;
|
|
+ if (buffer->priv->unref_func){
|
|
+ buffer->priv->unref_func (buffer, buffer->priv->unref_func_data);
|
|
}
|
|
- if (buffer->private->ref_count == 0 ){
|
|
- sem_post (&buffer->private->lock);
|
|
+ if (buffer->priv->ref_count == 0 ){
|
|
+ sem_post (&buffer->priv->lock);
|
|
unicap_data_buffer_free( buffer );
|
|
return STATUS_SUCCESS;
|
|
}
|
|
@@ -1529,23 +1529,23 @@ unicap_status_t unicap_data_buffer_unref( unicap_data_buffer_t *buffer )
|
|
TRACE( "unref of a buffer with refcount <= 0!" );
|
|
status = STATUS_FAILURE;
|
|
}
|
|
- sem_post (&buffer->private->lock);
|
|
+ sem_post (&buffer->priv->lock);
|
|
return status;
|
|
}
|
|
|
|
unsigned int unicap_data_buffer_get_refcount( unicap_data_buffer_t *buffer )
|
|
{
|
|
- return buffer->private->ref_count;
|
|
+ return buffer->priv->ref_count;
|
|
}
|
|
|
|
void *unicap_data_buffer_set_user_data( unicap_data_buffer_t *buffer, void *data )
|
|
{
|
|
- void *old_data = buffer->private->user_data;
|
|
- buffer->private->user_data = data;
|
|
+ void *old_data = buffer->priv->user_data;
|
|
+ buffer->priv->user_data = data;
|
|
return old_data;
|
|
}
|
|
|
|
void *unicap_data_buffer_get_user_data( unicap_data_buffer_t *buffer )
|
|
{
|
|
- return buffer->private->user_data;
|
|
+ return buffer->priv->user_data;
|
|
}
|