ringbuffer.h

Go to the documentation of this file.
00001 /*
00002   Copyright (C) 2000 Paul Davis
00003   Copyright (C) 2003 Rohan Drape
00004   
00005   This program is free software; you can redistribute it and/or modify
00006   it under the terms of the GNU Lesser General Public License as published by
00007   the Free Software Foundation; either version 2.1 of the License, or
00008   (at your option) any later version.
00009   
00010   This program is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013   GNU Lesser General Public License for more details.
00014   
00015   You should have received a copy of the GNU Lesser General Public License
00016   along with this program; if not, write to the Free Software 
00017   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00018 
00019   $Id: ringbuffer.h,v 1.2.2.1 2006/06/20 14:44:00 letz Exp $
00020 */
00021 
00022 #ifndef _RINGBUFFER_H
00023 #define _RINGBUFFER_H
00024 
00025 #ifdef __cplusplus
00026 extern "C"
00027 {
00028 #endif
00029 
00030 #include <sys/types.h>
00031 
00046     typedef struct {
00047         char *buf;
00048         size_t len;
00049     }
00050     jack_ringbuffer_data_t ;
00051 
00052     typedef struct {
00053         char    *buf;
00054         volatile size_t write_ptr;
00055         volatile size_t read_ptr;
00056         size_t  size;
00057         size_t  size_mask;
00058         int     mlocked;
00059     }
00060     jack_ringbuffer_t ;
00061 
00072     jack_ringbuffer_t *jack_ringbuffer_create(size_t sz);
00073 
00080     void jack_ringbuffer_free(jack_ringbuffer_t *rb);
00081 
00102     void jack_ringbuffer_get_read_vector(const jack_ringbuffer_t *rb,
00103                                          jack_ringbuffer_data_t *vec);
00104 
00124     void jack_ringbuffer_get_write_vector(const jack_ringbuffer_t *rb,
00125                                           jack_ringbuffer_data_t *vec);
00126 
00137     size_t jack_ringbuffer_read(jack_ringbuffer_t *rb, char *dest, size_t cnt);
00138 
00154     size_t jack_ringbuffer_peek(jack_ringbuffer_t *rb, char *dest, size_t cnt);
00155 
00167     void jack_ringbuffer_read_advance(jack_ringbuffer_t *rb, size_t cnt);
00168 
00176     size_t jack_ringbuffer_read_space(const jack_ringbuffer_t *rb);
00177 
00185     int jack_ringbuffer_mlock(jack_ringbuffer_t *rb);
00186 
00194     void jack_ringbuffer_reset(jack_ringbuffer_t *rb);
00195 
00205     size_t jack_ringbuffer_write(jack_ringbuffer_t *rb, const char *src,
00206                                  size_t cnt);
00207 
00219     void jack_ringbuffer_write_advance(jack_ringbuffer_t *rb, size_t cnt);
00220 
00228     size_t jack_ringbuffer_write_space(const jack_ringbuffer_t *rb);
00229 
00230 
00231 #ifdef __cplusplus
00232 }
00233 #endif
00234 
00235 #endif

Generated on Wed Jan 10 11:42:47 2007 for Jackdmp by  doxygen 1.4.5