Show
Ignore:
Timestamp:
04/02/07 12:35:17 (14 years ago)
Author:
pieterpalmers
Message:

* name change from FreeBoB to FFADO
* replaced tabs by 4 spaces
* got rid of end-of-line spaces
* made all license and copyrights conform

library becomes LGPL, apps become GPL
explicitly state LGPL v2.1 and GPL v2 (don't like v3 draft)

copyrights are 2005-2007 Daniel & Pieter
except for the MotU stuff (C) Jonathan, Pieter

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/src/libutil/ringbuffer.h

    r386 r445  
    33  function names changed in order to avoid naming problems when using this in 
    44  a jackd backend. 
    5    
    6   Modifications for FreeBoB by Pieter Palmers 
    7      
     5 
     6  Modifications for FFADO by Pieter Palmers 
     7 
    88    Copyright (C) 2000 Paul Davis 
    99    Copyright (C) 2003 Rohan Drape 
    10      
     10 
    1111    This program is free software; you can redistribute it and/or modify 
    1212    it under the terms of the GNU Lesser General Public License as published by 
    1313    the Free Software Foundation; either version 2.1 of the License, or 
    1414    (at your option) any later version. 
    15      
     15 
    1616    This program is distributed in the hope that it will be useful, 
    1717    but WITHOUT ANY WARRANTY; without even the implied warranty of 
    1818    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1919    GNU Lesser General Public License for more details. 
    20      
     20 
    2121    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 
    2323    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
    2424 
    2525*/ 
    2626 
    27 #ifndef _RINGBUFFER_H 
    28 #define _RINGBUFFER_H 
     27#ifndef _FFADO_RINGBUFFER_H 
     28#define _FFADO_RINGBUFFER_H 
    2929 
    3030#ifdef __cplusplus 
     
    4545 */ 
    4646 
    47 typedef struct   
     47typedef struct 
    4848{ 
    4949  char  *buf; 
    5050  size_t len; 
    51 }  
    52 freebob_ringbuffer_data_t ; 
     51} 
     52ffado_ringbuffer_data_t ; 
    5353 
    5454typedef struct 
    5555{ 
    56   char          *buf; 
     56  char        *buf; 
    5757  volatile size_t write_ptr; 
    5858  volatile size_t read_ptr; 
    59   size_t         size; 
    60   size_t         size_mask; 
    61   int            mlocked; 
    62 }  
    63 freebob_ringbuffer_t ; 
     59  size_t      size; 
     60  size_t      size_mask; 
     61  int          mlocked; 
     62} 
     63ffado_ringbuffer_t ; 
    6464 
    6565/** 
    6666 * Allocates a ringbuffer data structure of a specified size. The 
    67  * caller must arrange for a call to freebob_ringbuffer_free() to release 
     67 * caller must arrange for a call to ffado_ringbuffer_free() to release 
    6868 * the memory associated with the ringbuffer. 
    6969 * 
    7070 * @param sz the ringbuffer size in bytes. 
    7171 * 
    72  * @return a pointer to a new freebob_ringbuffer_t, if successful; NULL 
     72 * @return a pointer to a new ffado_ringbuffer_t, if successful; NULL 
    7373 * otherwise. 
    7474 */ 
    75 freebob_ringbuffer_t *freebob_ringbuffer_create(size_t sz); 
     75ffado_ringbuffer_t *ffado_ringbuffer_create(size_t sz); 
    7676 
    7777/** 
    7878 * Frees the ringbuffer data structure allocated by an earlier call to 
    79  * freebob_ringbuffer_create(). 
    80  * 
    81  * @param rb a pointer to the ringbuffer structure. 
    82  */ 
    83 void freebob_ringbuffer_free(freebob_ringbuffer_t *rb); 
     79 * ffado_ringbuffer_create(). 
     80 * 
     81 * @param rb a pointer to the ringbuffer structure. 
     82 */ 
     83void ffado_ringbuffer_free(ffado_ringbuffer_t *rb); 
    8484 
    8585/** 
    8686 * Fill a data structure with a description of the current readable 
    8787 * data held in the ringbuffer.  This description is returned in a two 
    88  * element array of freebob_ringbuffer_data_t.  Two elements are needed 
     88 * element array of ffado_ringbuffer_data_t.  Two elements are needed 
    8989 * because the data to be read may be split across the end of the 
    9090 * ringbuffer. 
     
    100100 * 
    101101 * @param rb a pointer to the ringbuffer structure. 
    102  * @param vec a pointer to a 2 element array of freebob_ringbuffer_data_t. 
    103  * 
    104  */ 
    105 void freebob_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 */ 
     105void ffado_ringbuffer_get_read_vector(const ffado_ringbuffer_t *rb, 
     106                     ffado_ringbuffer_data_t *vec); 
    107107 
    108108/** 
    109109 * Fill a data structure with a description of the current writable 
    110110 * space in the ringbuffer.  The description is returned in a two 
    111  * element array of freebob_ringbuffer_data_t.  Two elements are needed 
     111 * element array of ffado_ringbuffer_data_t.  Two elements are needed 
    112112 * because the space available for writing may be split across the end 
    113113 * of the ringbuffer. 
     
    123123 * 
    124124 * @param rb a pointer to the ringbuffer structure. 
    125  * @param vec a pointer to a 2 element array of freebob_ringbuffer_data_t. 
    126  */ 
    127 void freebob_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 */ 
     127void ffado_ringbuffer_get_write_vector(const ffado_ringbuffer_t *rb, 
     128                      ffado_ringbuffer_data_t *vec); 
    129129 
    130130/** 
     
    138138 * @return the number of bytes read, which may range from 0 to cnt. 
    139139 */ 
    140 size_t freebob_ringbuffer_read(freebob_ringbuffer_t *rb, char *dest, size_t cnt); 
    141  
    142 /** 
    143  * Read data from the ringbuffer. Opposed to freebob_ringbuffer_read() 
     140size_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() 
    144144 * this function does not move the read pointer. Thus it's 
    145145 * a convenient way to inspect data in the ringbuffer in a 
    146146 * continous fashion. The price is that the data is copied 
    147147 * into a user provided buffer. For "raw" non-copy inspection 
    148  * of the data in the ringbuffer use freebob_ringbuffer_get_read_vector(). 
     148 * of the data in the ringbuffer use ffado_ringbuffer_get_read_vector(). 
    149149 * 
    150150 * @param rb a pointer to the ringbuffer structure. 
     
    155155 * @return the number of bytes read, which may range from 0 to cnt. 
    156156 */ 
    157 size_t freebob_ringbuffer_peek(freebob_ringbuffer_t *rb, char *dest, size_t cnt); 
     157size_t ffado_ringbuffer_peek(ffado_ringbuffer_t *rb, char *dest, size_t cnt); 
    158158 
    159159/** 
     
    161161 * 
    162162 * After data have been read from the ringbuffer using the pointers 
    163  * returned by freebob_ringbuffer_get_read_vector(), use this function to 
     163 * returned by ffado_ringbuffer_get_read_vector(), use this function to 
    164164 * advance the buffer pointers, making that space available for future 
    165165 * write operations. 
     
    168168 * @param cnt the number of bytes read. 
    169169 */ 
    170 void freebob_ringbuffer_read_advance(freebob_ringbuffer_t *rb, size_t cnt); 
     170void ffado_ringbuffer_read_advance(ffado_ringbuffer_t *rb, size_t cnt); 
    171171 
    172172/** 
     
    177177 * @return the number of bytes available to read. 
    178178 */ 
    179 size_t freebob_ringbuffer_read_space(const freebob_ringbuffer_t *rb); 
     179size_t ffado_ringbuffer_read_space(const ffado_ringbuffer_t *rb); 
    180180 
    181181/** 
     
    186186 * @param rb a pointer to the ringbuffer structure. 
    187187 */ 
    188 int freebob_ringbuffer_mlock(freebob_ringbuffer_t *rb); 
     188int ffado_ringbuffer_mlock(ffado_ringbuffer_t *rb); 
    189189 
    190190/** 
     
    195195 * @param rb a pointer to the ringbuffer structure. 
    196196 */ 
    197 void freebob_ringbuffer_reset(freebob_ringbuffer_t *rb); 
     197void ffado_ringbuffer_reset(ffado_ringbuffer_t *rb); 
    198198 
    199199/** 
     
    206206 * @return the number of bytes write, which may range from 0 to cnt 
    207207 */ 
    208 size_t freebob_ringbuffer_write(freebob_ringbuffer_t *rb, const char *src, 
    209                             size_t cnt); 
     208size_t ffado_ringbuffer_write(ffado_ringbuffer_t *rb, const char *src, 
     209                 size_t cnt); 
    210210 
    211211/** 
     
    213213 * 
    214214 * After data have been written the ringbuffer using the pointers 
    215  * returned by freebob_ringbuffer_get_write_vector(), use this function 
     215 * returned by ffado_ringbuffer_get_write_vector(), use this function 
    216216 * to advance the buffer pointer, making the data available for future 
    217217 * read operations. 
     
    220220 * @param cnt the number of bytes written. 
    221221 */ 
    222 void freebob_ringbuffer_write_advance(freebob_ringbuffer_t *rb, size_t cnt); 
     222void ffado_ringbuffer_write_advance(ffado_ringbuffer_t *rb, size_t cnt); 
    223223 
    224224/** 
     
    229229 * @return the amount of free space (in bytes) available for writing. 
    230230 */ 
    231 size_t freebob_ringbuffer_write_space(const freebob_ringbuffer_t *rb); 
     231size_t ffado_ringbuffer_write_space(const ffado_ringbuffer_t *rb); 
    232232 
    233233 
     
    236236#endif 
    237237 
    238 #endif 
     238#endif // FFADO_RINGBUFFER