JACK-AUDIO-CONNECTION-KIT: ringbuffer.h Source File

# 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 */
    00020
    00021 #ifndef _RINGBUFFER_H
    00022 #define _RINGBUFFER_H
    00023
    00024 #ifdef __cplusplus
    00025 extern "C" {
    00026 #endif
    00027
    00028 #include <sys/types.h>
    00029
    00044 typedef struct
    00045 {
    00046   char  *buf;
    00047   size_t len;
    00048 }
    00049 jack_ringbuffer_data_t ;
    00050
    00051 typedef struct
    00052 {
    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