pa_ringbuffer.h

Go to the documentation of this file.
00001 #ifndef PA_RINGBUFFER_H
00002 #define PA_RINGBUFFER_H
00003 /*
00004  * $Id: pa_ringbuffer.h 1347 2008-02-21 04:54:36Z rossb $
00005  * Portable Audio I/O Library
00006  * Ring Buffer utility.
00007  *
00008  * Author: Phil Burk, http://www.softsynth.com
00009  * modified for SMP safety on OS X by Bjorn Roche.
00010  * also allowed for const where possible.
00011  * modified for multiple-byte-sized data elements by Sven Fischer 
00012  *
00013  * Note that this is safe only for a single-thread reader
00014  * and a single-thread writer.
00015  *
00016  * This program is distributed with the PortAudio Portable Audio Library.
00017  * For more information see: http://www.portaudio.com
00018  * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
00019  *
00020  * Permission is hereby granted, free of charge, to any person obtaining
00021  * a copy of this software and associated documentation files
00022  * (the "Software"), to deal in the Software without restriction,
00023  * including without limitation the rights to use, copy, modify, merge,
00024  * publish, distribute, sublicense, and/or sell copies of the Software,
00025  * and to permit persons to whom the Software is furnished to do so,
00026  * subject to the following conditions:
00027  *
00028  * The above copyright notice and this permission notice shall be
00029  * included in all copies or substantial portions of the Software.
00030  *
00031  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00032  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00033  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00034  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
00035  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
00036  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
00037  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00038  */
00039 
00040 /*
00041  * The text above constitutes the entire PortAudio license; however, 
00042  * the PortAudio community also makes the following non-binding requests:
00043  *
00044  * Any person wishing to distribute modifications to the Software is
00045  * requested to send the modifications to the original developer so that
00046  * they can be incorporated into the canonical version. It is also 
00047  * requested that these non-binding requests be included along with the 
00048  * license above.
00049  */
00050 
00070 #ifdef __cplusplus
00071 extern "C"
00072 {
00073 #endif /* __cplusplus */
00074 
00075 typedef struct PaUtilRingBuffer
00076 {
00077     long  bufferSize; 
00078     long  writeIndex; 
00079     long  readIndex;  
00080     long  bigMask;    
00081     long  smallMask;  
00082     long  elementSizeBytes; 
00083     char  *buffer;    
00084 }PaUtilRingBuffer;
00085 
00099 long PaUtil_InitializeRingBuffer( PaUtilRingBuffer *rbuf, long elementSizeBytes, long elementCount, void *dataPtr );
00100 
00105 void PaUtil_FlushRingBuffer( PaUtilRingBuffer *rbuf );
00106 
00113 long PaUtil_GetRingBufferWriteAvailable( PaUtilRingBuffer *rbuf );
00114 
00121 long PaUtil_GetRingBufferReadAvailable( PaUtilRingBuffer *rbuf );
00122 
00133 long PaUtil_WriteRingBuffer( PaUtilRingBuffer *rbuf, const void *data, long elementCount );
00134 
00145 long PaUtil_ReadRingBuffer( PaUtilRingBuffer *rbuf, void *data, long elementCount );
00146 
00167 long PaUtil_GetRingBufferWriteRegions( PaUtilRingBuffer *rbuf, long elementCount,
00168                                        void **dataPtr1, long *sizePtr1,
00169                                        void **dataPtr2, long *sizePtr2 );
00170 
00179 long PaUtil_AdvanceRingBufferWriteIndex( PaUtilRingBuffer *rbuf, long elementCount );
00180 
00201 long PaUtil_GetRingBufferReadRegions( PaUtilRingBuffer *rbuf, long elementCount,
00202                                       void **dataPtr1, long *sizePtr1,
00203                                       void **dataPtr2, long *sizePtr2 );
00204 
00213 long PaUtil_AdvanceRingBufferReadIndex( PaUtilRingBuffer *rbuf, long elementCount );
00214 
00215 #ifdef __cplusplus
00216 }
00217 #endif /* __cplusplus */
00218 #endif /* PA_RINGBUFFER_H */

Generated on Thu Nov 20 00:37:04 2008 for PortAudio by  doxygen 1.4.7