summaryrefslogtreecommitdiff
path: root/libs/fluidsynth/src/fluid_ringbuffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'libs/fluidsynth/src/fluid_ringbuffer.c')
-rw-r--r--libs/fluidsynth/src/fluid_ringbuffer.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/libs/fluidsynth/src/fluid_ringbuffer.c b/libs/fluidsynth/src/fluid_ringbuffer.c
index f6c06dd76d..71fd1e48a3 100644
--- a/libs/fluidsynth/src/fluid_ringbuffer.c
+++ b/libs/fluidsynth/src/fluid_ringbuffer.c
@@ -3,16 +3,16 @@
* Copyright (C) 2003 Peter Hanappe and others.
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public License
- * as published by the Free Software Foundation; either version 2 of
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA
@@ -39,39 +39,39 @@
* only be one producer thread and one consumer thread.
*/
fluid_ringbuffer_t *
-new_fluid_ringbuffer (int count, int elementsize)
+new_fluid_ringbuffer(int count, int elementsize)
{
- fluid_ringbuffer_t *queue;
+ fluid_ringbuffer_t *queue;
- fluid_return_val_if_fail (count > 0, NULL);
+ fluid_return_val_if_fail(count > 0, NULL);
- queue = FLUID_NEW (fluid_ringbuffer_t);
+ queue = FLUID_NEW(fluid_ringbuffer_t);
- if (!queue)
- {
- FLUID_LOG (FLUID_ERR, "Out of memory");
- return NULL;
- }
+ if(!queue)
+ {
+ FLUID_LOG(FLUID_ERR, "Out of memory");
+ return NULL;
+ }
- queue->array = FLUID_MALLOC (elementsize * count);
+ queue->array = FLUID_MALLOC(elementsize * count);
- if (!queue->array)
- {
- FLUID_FREE (queue);
- FLUID_LOG (FLUID_ERR, "Out of memory");
- return NULL;
- }
+ if(!queue->array)
+ {
+ FLUID_LOG(FLUID_ERR, "Out of memory");
+ delete_fluid_ringbuffer(queue);
+ return NULL;
+ }
- /* Clear array, in case dynamic pointer reclaiming is being done */
- FLUID_MEMSET (queue->array, 0, elementsize * count);
+ /* Clear array, in case dynamic pointer reclaiming is being done */
+ FLUID_MEMSET(queue->array, 0, elementsize * count);
- queue->totalcount = count;
- queue->elementsize = elementsize;
- queue->count = 0;
- queue->in = 0;
- queue->out = 0;
+ queue->totalcount = count;
+ queue->elementsize = elementsize;
+ fluid_atomic_int_set(&queue->count, 0);
+ queue->in = 0;
+ queue->out = 0;
- return (queue);
+ return (queue);
}
/**
@@ -82,8 +82,9 @@ new_fluid_ringbuffer (int count, int elementsize)
* producer threads will no longer access it.
*/
void
-delete_fluid_ringbuffer (fluid_ringbuffer_t *queue)
+delete_fluid_ringbuffer(fluid_ringbuffer_t *queue)
{
- FLUID_FREE (queue->array);
- FLUID_FREE (queue);
+ fluid_return_if_fail(queue != NULL);
+ FLUID_FREE(queue->array);
+ FLUID_FREE(queue);
}