Jack2 1.9.6
|
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 */ 00020 00021 #ifndef _RINGBUFFER_H 00022 #define _RINGBUFFER_H 00023 00024 #ifdef __cplusplus 00025 extern "C" 00026 { 00027 #endif 00028 00029 #include <sys/types.h> 00030 00045 typedef struct { 00046 char *buf; 00047 size_t len; 00048 } 00049 jack_ringbuffer_data_t ; 00050 00051 typedef struct { 00052 char *buf; 00053 volatile size_t write_ptr; 00054 volatile size_t read_ptr; 00055 size_t size; 00056 size_t size_mask; 00057 int mlocked; 00058 } 00059 jack_ringbuffer_t ; 00060 00071 jack_ringbuffer_t *jack_ringbuffer_create(size_t sz); 00072 00079 void jack_ringbuffer_free(jack_ringbuffer_t *rb); 00080 00101 void jack_ringbuffer_get_read_vector(const jack_ringbuffer_t *rb, 00102 jack_ringbuffer_data_t *vec); 00103 00123 void jack_ringbuffer_get_write_vector(const jack_ringbuffer_t *rb, 00124 jack_ringbuffer_data_t *vec); 00125 00136 size_t jack_ringbuffer_read(jack_ringbuffer_t *rb, char *dest, size_t cnt); 00137 00153 size_t jack_ringbuffer_peek(jack_ringbuffer_t *rb, char *dest, size_t cnt); 00154 00166 void jack_ringbuffer_read_advance(jack_ringbuffer_t *rb, size_t cnt); 00167 00175 size_t jack_ringbuffer_read_space(const jack_ringbuffer_t *rb); 00176 00184 int jack_ringbuffer_mlock(jack_ringbuffer_t *rb); 00185 00193 void jack_ringbuffer_reset(jack_ringbuffer_t *rb); 00194 00203 void jack_ringbuffer_reset_size (jack_ringbuffer_t * rb, size_t sz); 00204 00214 size_t jack_ringbuffer_write(jack_ringbuffer_t *rb, const char *src, 00215 size_t cnt); 00216 00228 void jack_ringbuffer_write_advance(jack_ringbuffer_t *rb, size_t cnt); 00229 00237 size_t jack_ringbuffer_write_space(const jack_ringbuffer_t *rb); 00238 00239 #ifdef __cplusplus 00240 } 00241 #endif 00242 00243 #endif