ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

common.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 /*
00020 ** This code is part of Secret Rabbit Code aka libsamplerate. A commercial
00021 ** use license for this code is available, please see:
00022 **      http://www.mega-nerd.com/SRC/procedure.html
00023 */
00024 
00025 #ifndef COMMON_H_INCLUDED
00026 #define COMMON_H_INCLUDED
00027 
00028 #ifdef HAVE_STDINT_H
00029 #include <stdint.h>
00030 #elif (SIZEOF_INT == 4)
00031 typedef int     int32_t ;
00032 #elif (SIZEOF_LONG == 4)
00033 typedef long    int32_t ;
00034 #endif
00035 
00036 #define SRC_MAX_RATIO           256
00037 #define SRC_MAX_RATIO_STR       "256"
00038 
00039 #define SRC_MIN_RATIO_DIFF      (1e-20)
00040 
00041 #define MAX(a,b)    (((a) > (b)) ? (a) : (b))
00042 #define MIN(a,b)    (((a) < (b)) ? (a) : (b))
00043 
00044 #define ARRAY_LEN(x)            ((int) (sizeof (x) / sizeof ((x) [0])))
00045 #define OFFSETOF(type,member)   ((int) (&((type*) 0)->member))
00046 
00047 #define MAKE_MAGIC(a,b,c,d,e,f) ((a) + ((b) << 4) + ((c) << 8) + ((d) << 12) + ((e) << 16) + ((f) << 20))
00048 
00049 /*
00050 ** Inspiration : http://sourcefrog.net/weblog/software/languages/C/unused.html
00051 */
00052 #ifdef UNUSED
00053 #elif defined (__GNUC__)
00054 #   define UNUSED(x) UNUSED_ ## x __attribute__ ((unused))
00055 #elif defined (__LCLINT__)
00056 #   define UNUSED(x) /*@unused@*/ x
00057 #else
00058 #   define UNUSED(x) x
00059 #endif
00060 
00061 #ifdef __GNUC__
00062 #   define WARN_UNUSED  __attribute__ ((warn_unused_result))
00063 #else
00064 #   define WARN_UNUSED
00065 #endif
00066 
00067 
00068 #include "samplerate.h"
00069 
00070 enum
00071 {   SRC_FALSE   = 0,
00072     SRC_TRUE    = 1,
00073 
00074     SRC_MODE_PROCESS    = 555,
00075     SRC_MODE_CALLBACK   = 556
00076 } ;
00077 
00078 enum
00079 {   SRC_ERR_NO_ERROR = 0,
00080 
00081     SRC_ERR_MALLOC_FAILED,
00082     SRC_ERR_BAD_STATE,
00083     SRC_ERR_BAD_DATA,
00084     SRC_ERR_BAD_DATA_PTR,
00085     SRC_ERR_NO_PRIVATE,
00086     SRC_ERR_BAD_SRC_RATIO,
00087     SRC_ERR_BAD_PROC_PTR,
00088     SRC_ERR_SHIFT_BITS,
00089     SRC_ERR_FILTER_LEN,
00090     SRC_ERR_BAD_CONVERTER,
00091     SRC_ERR_BAD_CHANNEL_COUNT,
00092     SRC_ERR_SINC_BAD_BUFFER_LEN,
00093     SRC_ERR_SIZE_INCOMPATIBILITY,
00094     SRC_ERR_BAD_PRIV_PTR,
00095     SRC_ERR_BAD_SINC_STATE,
00096     SRC_ERR_DATA_OVERLAP,
00097     SRC_ERR_BAD_CALLBACK,
00098     SRC_ERR_BAD_MODE,
00099     SRC_ERR_NULL_CALLBACK,
00100     SRC_ERR_NO_VARIABLE_RATIO,
00101     SRC_ERR_SINC_PREPARE_DATA_BAD_LEN,
00102 
00103     /* This must be the last error number. */
00104     SRC_ERR_MAX_ERROR
00105 } ;
00106 
00107 typedef struct SRC_PRIVATE_tag
00108 {   double  last_ratio, last_position ;
00109 
00110     int     error ;
00111     int     channels ;
00112 
00113     /* SRC_MODE_PROCESS or SRC_MODE_CALLBACK */
00114     int     mode ;
00115 
00116     /* Pointer to data to converter specific data. */
00117     void    *private_data ;
00118 
00119     /* Varispeed process function. */
00120     int     (*vari_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
00121 
00122     /* Constant speed process function. */
00123     int     (*const_process) (struct SRC_PRIVATE_tag *psrc, SRC_DATA *data) ;
00124 
00125     /* State reset. */
00126     void    (*reset) (struct SRC_PRIVATE_tag *psrc) ;
00127 
00128     /* Data specific to SRC_MODE_CALLBACK. */
00129     src_callback_t  callback_func ;
00130     void            *user_callback_data ;
00131     long            saved_frames ;
00132     float           *saved_data ;
00133 } SRC_PRIVATE ;
00134 
00135 /* In src_sinc.c */
00136 const char* sinc_get_name (int src_enum) ;
00137 const char* sinc_get_description (int src_enum) ;
00138 
00139 int sinc_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
00140 
00141 /* In src_linear.c */
00142 const char* linear_get_name (int src_enum) ;
00143 const char* linear_get_description (int src_enum) ;
00144 
00145 int linear_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
00146 
00147 /* In src_zoh.c */
00148 const char* zoh_get_name (int src_enum) ;
00149 const char* zoh_get_description (int src_enum) ;
00150 
00151 int zoh_set_converter (SRC_PRIVATE *psrc, int src_enum) ;
00152 
00153 /*----------------------------------------------------------
00154 **  Common static inline functions.
00155 */
00156 
00157 static inline double
00158 fmod_one (double x)
00159 {   double res ;
00160 
00161     res = x - lrint (x) ;
00162     if (res < 0.0)
00163         return res + 1.0 ;
00164 
00165     return res ;
00166 } /* fmod_one */
00167 
00168 #endif  /* COMMON_H_INCLUDED */
00169 

Generated on Sat May 26 2012 04:31:54 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.