Changeset 445 for trunk/libffado/src/libutil/ringbuffer.h
- Timestamp:
- 04/02/07 12:35:17 (14 years ago)
- Files:
-
- trunk/libffado/src/libutil/ringbuffer.h (modified) (16 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libffado/src/libutil/ringbuffer.h
r386 r445 3 3 function names changed in order to avoid naming problems when using this in 4 4 a jackd backend. 5 6 Modifications for F reeBoBby Pieter Palmers7 5 6 Modifications for FFADO by Pieter Palmers 7 8 8 Copyright (C) 2000 Paul Davis 9 9 Copyright (C) 2003 Rohan Drape 10 10 11 11 This program is free software; you can redistribute it and/or modify 12 12 it under the terms of the GNU Lesser General Public License as published by 13 13 the Free Software Foundation; either version 2.1 of the License, or 14 14 (at your option) any later version. 15 15 16 16 This program is distributed in the hope that it will be useful, 17 17 but WITHOUT ANY WARRANTY; without even the implied warranty of 18 18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19 19 GNU Lesser General Public License for more details. 20 20 21 21 You should have received a copy of the GNU Lesser General Public License 22 along with this program; if not, write to the Free Software 22 along with this program; if not, write to the Free Software 23 23 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 24 24 25 25 */ 26 26 27 #ifndef _ RINGBUFFER_H28 #define _ RINGBUFFER_H27 #ifndef _FFADO_RINGBUFFER_H 28 #define _FFADO_RINGBUFFER_H 29 29 30 30 #ifdef __cplusplus … … 45 45 */ 46 46 47 typedef struct 47 typedef struct 48 48 { 49 49 char *buf; 50 50 size_t len; 51 } 52 f reebob_ringbuffer_data_t ;51 } 52 ffado_ringbuffer_data_t ; 53 53 54 54 typedef struct 55 55 { 56 char 56 char *buf; 57 57 volatile size_t write_ptr; 58 58 volatile size_t read_ptr; 59 size_t 60 size_t 61 int 62 } 63 f reebob_ringbuffer_t ;59 size_t size; 60 size_t size_mask; 61 int mlocked; 62 } 63 ffado_ringbuffer_t ; 64 64 65 65 /** 66 66 * Allocates a ringbuffer data structure of a specified size. The 67 * caller must arrange for a call to f reebob_ringbuffer_free() to release67 * caller must arrange for a call to ffado_ringbuffer_free() to release 68 68 * the memory associated with the ringbuffer. 69 69 * 70 70 * @param sz the ringbuffer size in bytes. 71 71 * 72 * @return a pointer to a new f reebob_ringbuffer_t, if successful; NULL72 * @return a pointer to a new ffado_ringbuffer_t, if successful; NULL 73 73 * otherwise. 74 74 */ 75 f reebob_ringbuffer_t *freebob_ringbuffer_create(size_t sz);75 ffado_ringbuffer_t *ffado_ringbuffer_create(size_t sz); 76 76 77 77 /** 78 78 * Frees the ringbuffer data structure allocated by an earlier call to 79 * f reebob_ringbuffer_create().80 * 81 * @param rb a pointer to the ringbuffer structure. 82 */ 83 void f reebob_ringbuffer_free(freebob_ringbuffer_t *rb);79 * ffado_ringbuffer_create(). 80 * 81 * @param rb a pointer to the ringbuffer structure. 82 */ 83 void ffado_ringbuffer_free(ffado_ringbuffer_t *rb); 84 84 85 85 /** 86 86 * Fill a data structure with a description of the current readable 87 87 * data held in the ringbuffer. This description is returned in a two 88 * element array of f reebob_ringbuffer_data_t. Two elements are needed88 * element array of ffado_ringbuffer_data_t. Two elements are needed 89 89 * because the data to be read may be split across the end of the 90 90 * ringbuffer. … … 100 100 * 101 101 * @param rb a pointer to the ringbuffer structure. 102 * @param vec a pointer to a 2 element array of f reebob_ringbuffer_data_t.103 * 104 */ 105 void f reebob_ringbuffer_get_read_vector(const freebob_ringbuffer_t *rb,106 freebob_ringbuffer_data_t *vec);102 * @param vec a pointer to a 2 element array of ffado_ringbuffer_data_t. 103 * 104 */ 105 void ffado_ringbuffer_get_read_vector(const ffado_ringbuffer_t *rb, 106 ffado_ringbuffer_data_t *vec); 107 107 108 108 /** 109 109 * Fill a data structure with a description of the current writable 110 110 * space in the ringbuffer. The description is returned in a two 111 * element array of f reebob_ringbuffer_data_t. Two elements are needed111 * element array of ffado_ringbuffer_data_t. Two elements are needed 112 112 * because the space available for writing may be split across the end 113 113 * of the ringbuffer. … … 123 123 * 124 124 * @param rb a pointer to the ringbuffer structure. 125 * @param vec a pointer to a 2 element array of f reebob_ringbuffer_data_t.126 */ 127 void f reebob_ringbuffer_get_write_vector(const freebob_ringbuffer_t *rb,128 freebob_ringbuffer_data_t *vec);125 * @param vec a pointer to a 2 element array of ffado_ringbuffer_data_t. 126 */ 127 void ffado_ringbuffer_get_write_vector(const ffado_ringbuffer_t *rb, 128 ffado_ringbuffer_data_t *vec); 129 129 130 130 /** … … 138 138 * @return the number of bytes read, which may range from 0 to cnt. 139 139 */ 140 size_t f reebob_ringbuffer_read(freebob_ringbuffer_t *rb, char *dest, size_t cnt);141 142 /** 143 * Read data from the ringbuffer. Opposed to f reebob_ringbuffer_read()140 size_t ffado_ringbuffer_read(ffado_ringbuffer_t *rb, char *dest, size_t cnt); 141 142 /** 143 * Read data from the ringbuffer. Opposed to ffado_ringbuffer_read() 144 144 * this function does not move the read pointer. Thus it's 145 145 * a convenient way to inspect data in the ringbuffer in a 146 146 * continous fashion. The price is that the data is copied 147 147 * into a user provided buffer. For "raw" non-copy inspection 148 * of the data in the ringbuffer use f reebob_ringbuffer_get_read_vector().148 * of the data in the ringbuffer use ffado_ringbuffer_get_read_vector(). 149 149 * 150 150 * @param rb a pointer to the ringbuffer structure. … … 155 155 * @return the number of bytes read, which may range from 0 to cnt. 156 156 */ 157 size_t f reebob_ringbuffer_peek(freebob_ringbuffer_t *rb, char *dest, size_t cnt);157 size_t ffado_ringbuffer_peek(ffado_ringbuffer_t *rb, char *dest, size_t cnt); 158 158 159 159 /** … … 161 161 * 162 162 * After data have been read from the ringbuffer using the pointers 163 * returned by f reebob_ringbuffer_get_read_vector(), use this function to163 * returned by ffado_ringbuffer_get_read_vector(), use this function to 164 164 * advance the buffer pointers, making that space available for future 165 165 * write operations. … … 168 168 * @param cnt the number of bytes read. 169 169 */ 170 void f reebob_ringbuffer_read_advance(freebob_ringbuffer_t *rb, size_t cnt);170 void ffado_ringbuffer_read_advance(ffado_ringbuffer_t *rb, size_t cnt); 171 171 172 172 /** … … 177 177 * @return the number of bytes available to read. 178 178 */ 179 size_t f reebob_ringbuffer_read_space(const freebob_ringbuffer_t *rb);179 size_t ffado_ringbuffer_read_space(const ffado_ringbuffer_t *rb); 180 180 181 181 /** … … 186 186 * @param rb a pointer to the ringbuffer structure. 187 187 */ 188 int f reebob_ringbuffer_mlock(freebob_ringbuffer_t *rb);188 int ffado_ringbuffer_mlock(ffado_ringbuffer_t *rb); 189 189 190 190 /** … … 195 195 * @param rb a pointer to the ringbuffer structure. 196 196 */ 197 void f reebob_ringbuffer_reset(freebob_ringbuffer_t *rb);197 void ffado_ringbuffer_reset(ffado_ringbuffer_t *rb); 198 198 199 199 /** … … 206 206 * @return the number of bytes write, which may range from 0 to cnt 207 207 */ 208 size_t f reebob_ringbuffer_write(freebob_ringbuffer_t *rb, const char *src,209 208 size_t ffado_ringbuffer_write(ffado_ringbuffer_t *rb, const char *src, 209 size_t cnt); 210 210 211 211 /** … … 213 213 * 214 214 * After data have been written the ringbuffer using the pointers 215 * returned by f reebob_ringbuffer_get_write_vector(), use this function215 * returned by ffado_ringbuffer_get_write_vector(), use this function 216 216 * to advance the buffer pointer, making the data available for future 217 217 * read operations. … … 220 220 * @param cnt the number of bytes written. 221 221 */ 222 void f reebob_ringbuffer_write_advance(freebob_ringbuffer_t *rb, size_t cnt);222 void ffado_ringbuffer_write_advance(ffado_ringbuffer_t *rb, size_t cnt); 223 223 224 224 /** … … 229 229 * @return the amount of free space (in bytes) available for writing. 230 230 */ 231 size_t f reebob_ringbuffer_write_space(const freebob_ringbuffer_t *rb);231 size_t ffado_ringbuffer_write_space(const ffado_ringbuffer_t *rb); 232 232 233 233 … … 236 236 #endif 237 237 238 #endif 238 #endif // FFADO_RINGBUFFER